mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
Update PostLayout.astro
This commit is contained in:
@@ -14,7 +14,9 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const { site } = config;
|
const { site } = config;
|
||||||
const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } = Astro.props;
|
|
||||||
|
const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } =
|
||||||
|
Astro.props;
|
||||||
|
|
||||||
const structuredData = {
|
const structuredData = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
@@ -23,16 +25,42 @@ const structuredData = {
|
|||||||
image: ogImage,
|
image: ogImage,
|
||||||
...(pubDatetime && { datePublished: pubDatetime.toISOString() }),
|
...(pubDatetime && { datePublished: pubDatetime.toISOString() }),
|
||||||
...(modDatetime && { dateModified: modDatetime.toISOString() }),
|
...(modDatetime && { dateModified: modDatetime.toISOString() }),
|
||||||
author: [{ "@type": "Person", name: site.author, ...(site.profile && { url: site.profile }) }],
|
author: [
|
||||||
|
{
|
||||||
|
"@type": "Person",
|
||||||
|
name: site.author,
|
||||||
|
...(site.profile && { url: site.profile }),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout {title} {description} {ogImage} {canonicalURL}>
|
<Layout {title} {description} {ogImage} {canonicalURL}>
|
||||||
<Fragment slot="head">
|
<Fragment slot="head">
|
||||||
<meta property="og:type" content="article" />
|
<meta property="og:type" content="article" />
|
||||||
{pubDatetime && <meta property="article:published_time" content={pubDatetime.toISOString()} />}
|
|
||||||
{modDatetime && <meta property="article:modified_time" content={modDatetime.toISOString()} />}
|
{
|
||||||
<script type="application/ld+json" is:inline set:html={JSON.stringify(structuredData)} />
|
pubDatetime && (
|
||||||
|
<meta
|
||||||
|
property="article:published_time"
|
||||||
|
content={pubDatetime.toISOString()}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
modDatetime && (
|
||||||
|
<meta
|
||||||
|
property="article:modified_time"
|
||||||
|
content={modDatetime.toISOString()}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
<script
|
||||||
|
type="application/ld+json"
|
||||||
|
is:inline
|
||||||
|
set:html={JSON.stringify(structuredData)}
|
||||||
|
/>
|
||||||
|
|
||||||
<link
|
<link
|
||||||
rel="preload"
|
rel="preload"
|
||||||
@@ -49,9 +77,7 @@ const structuredData = {
|
|||||||
></script>
|
></script>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|
||||||
<article class="prose prose-lg max-w-3xl mx-auto px-4">
|
<slot />
|
||||||
<slot />
|
|
||||||
</article>
|
|
||||||
|
|
||||||
<div class="max-w-3xl mx-auto px-4 mt-8 w-full">
|
<div class="max-w-3xl mx-auto px-4 mt-8 w-full">
|
||||||
<Comment />
|
<Comment />
|
||||||
|
|||||||
Reference in New Issue
Block a user