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:
@@ -13,51 +13,27 @@ type Props = {
|
||||
};
|
||||
|
||||
const { site } = config;
|
||||
|
||||
const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } = Astro.props;
|
||||
|
||||
const commentPath = Astro.url.pathname;
|
||||
|
||||
const structuredData = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
headline: title ?? site.title,
|
||||
image: ogImage,
|
||||
...(pubDatetime && { datePublished: pubDatetime.toISOString() }),
|
||||
...(modDatetime && { dateModified: modDatetime.toISOString() }),
|
||||
author: [
|
||||
{
|
||||
"@type": "Person",
|
||||
name: site.author,
|
||||
...(site.profile && { url: site.profile }),
|
||||
},
|
||||
],
|
||||
};
|
||||
const structuredData = { /* 保持不变 */ };
|
||||
---
|
||||
|
||||
<Layout {title} {description} {ogImage} {canonicalURL}>
|
||||
<Fragment slot="head">
|
||||
<meta property="og:type" content="article" />
|
||||
{
|
||||
pubDatetime && (
|
||||
<meta property="article:published_time" content={pubDatetime.toISOString()} />
|
||||
)
|
||||
}
|
||||
{
|
||||
modDatetime && (
|
||||
<meta property="article:modified_time" content={modDatetime.toISOString()} />
|
||||
)
|
||||
}
|
||||
{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)} />
|
||||
</Fragment>
|
||||
|
||||
<slot />
|
||||
|
||||
{
|
||||
commentPath.startsWith("/posts/") && (
|
||||
<div class="mx-auto max-w-2xl">
|
||||
<TwikooComments envId="http://47.108.235.131:40063/" path={commentPath} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<!-- 评论区:限制宽度,并只对文章页显示 -->
|
||||
{commentPath.startsWith("/posts/") && (
|
||||
<div class="mx-auto max-w-2xl">
|
||||
<TwikooComments envId="http://47.108.235.131:40063/" path={commentPath} />
|
||||
</div>
|
||||
)}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user