🔍 Optimize post SEO
This commit is contained in:
parent
87d728b022
commit
4d21f3463a
@ -3,7 +3,7 @@ export const prerender = false
|
|||||||
|
|
||||||
import sanitizeHtml from 'sanitize-html'
|
import sanitizeHtml from 'sanitize-html'
|
||||||
import { Icon } from 'astro-icon/components'
|
import { Icon } from 'astro-icon/components'
|
||||||
import {SEO} from 'astro-seo'
|
import { SEO } from 'astro-seo'
|
||||||
import { marked } from 'marked'
|
import { marked } from 'marked'
|
||||||
|
|
||||||
import Layout from '@/layouts/Layout.astro'
|
import Layout from '@/layouts/Layout.astro'
|
||||||
@ -30,33 +30,54 @@ const attachments = await fetchAttachmentMeta(data.body.attachments)
|
|||||||
---
|
---
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<SEO
|
<SEO
|
||||||
title={data.body?.title ? data.body.title : `Post #${data.id}`}
|
title={data.body?.title ? data.body.title : `Post #${data.id}`}
|
||||||
description={data.body?.content}
|
description={data.body?.content}
|
||||||
openGraph={{
|
openGraph={{
|
||||||
basic: {
|
optional: {
|
||||||
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
siteName: "Solar Network",
|
||||||
type: "article",
|
description: data.body?.description ?? data.body?.content?.substring(0, 200),
|
||||||
image: data.body?.thumbnail ? getAttachmentUrl(data.body.thumbnail) : getAttachmentUrl(attachments.find(a => a.mimetype.startsWith('image'))?.rid),
|
video: getAttachmentUrl(
|
||||||
url: `https://solsynth.dev/posts/${data.id}`
|
attachments.find((a) => a.mimetype.startsWith('video'))?.rid
|
||||||
},
|
),
|
||||||
article: {
|
audio: getAttachmentUrl(
|
||||||
publishedTime: new Date(data.created_at).toISOString(),
|
attachments.find((a) => a.mimetype.startsWith('audio'))?.rid
|
||||||
modifiedTime: new Date(data.updated_at).toISOString(),
|
),
|
||||||
authors: ["@"+data.publisher.name],
|
},
|
||||||
}
|
basic: {
|
||||||
}}
|
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
||||||
twitter={{
|
type: 'article',
|
||||||
card: "summary_large_image",
|
image: data.body?.thumbnail
|
||||||
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
? getAttachmentUrl(data.body.thumbnail)
|
||||||
description: data.body?.content,
|
: getAttachmentUrl(
|
||||||
creator: "@"+data.publisher.name,
|
attachments.find((a) => a.mimetype.startsWith('image'))?.rid
|
||||||
image: data.body?.thumbnail ? getAttachmentUrl(data.body.thumbnail) : getAttachmentUrl(attachments.find(a => a.mimetype.startsWith('image'))?.rid),
|
),
|
||||||
}}
|
url: `https://solsynth.dev/posts/${data.id}`,
|
||||||
/>
|
},
|
||||||
|
article: {
|
||||||
|
publishedTime: new Date(data.created_at).toISOString(),
|
||||||
|
modifiedTime: new Date(data.updated_at).toISOString(),
|
||||||
|
authors: ['@' + data.publisher.name],
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
twitter={{
|
||||||
|
card: 'summary_large_image',
|
||||||
|
title: data.body?.title ? data.body.title : `Post #${data.id}`,
|
||||||
|
description: data.body?.description,
|
||||||
|
creator: '@' + data.publisher.name,
|
||||||
|
image: data.body?.thumbnail
|
||||||
|
? getAttachmentUrl(data.body.thumbnail)
|
||||||
|
: getAttachmentUrl(
|
||||||
|
attachments.find((a) => a.mimetype.startsWith('image'))?.rid
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<Layout title={data.body?.title ? data.body.title : `Post #${data.id}`} trailingTitle='Solar Network'>
|
<Layout
|
||||||
|
title={data.body?.title ? data.body.title : `Post #${data.id}`}
|
||||||
|
trailingTitle="Solar Network"
|
||||||
|
>
|
||||||
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
<div role="alert" class="alert shadow-lg px-12 m-0 rounded-none mb-5">
|
||||||
<Icon
|
<Icon
|
||||||
name="material-symbols:ungroup"
|
name="material-symbols:ungroup"
|
||||||
|
Loading…
Reference in New Issue
Block a user