mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Update PostLayout.astro
This commit is contained in:
@@ -17,23 +17,37 @@ const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } =
|
|||||||
|
|
||||||
const commentPath = Astro.url.pathname;
|
const commentPath = Astro.url.pathname;
|
||||||
|
|
||||||
const structuredData = { /* ...保持不变... */ };
|
// 结构化数据(保持你原来的实现,此处仅作示例)
|
||||||
|
const structuredData = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "Article",
|
||||||
|
headline: title,
|
||||||
|
description: description,
|
||||||
|
// ... 其他字段按你的原有逻辑填充
|
||||||
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<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()} />}
|
{pubDatetime && (
|
||||||
{modDatetime && <meta property="article:modified_time" content={modDatetime.toISOString()} />}
|
<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)} />
|
<script type="application/ld+json" is:inline set:html={JSON.stringify(structuredData)} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
|
||||||
|
<!-- 文章主体内容(来自各个 Markdown 文件中的内容) -->
|
||||||
<slot />
|
<slot />
|
||||||
</Layout>
|
|
||||||
|
|
||||||
<!-- 评论区放在 Layout 外面,自然位于 Footer 之上(只要 Layout 外没有固定定位) -->
|
<!-- 仅在文章页面显示评论区,并通过插槽放到 footer 之前 -->
|
||||||
{commentPath.startsWith("/posts/") && (
|
{commentPath.startsWith("/posts/") && (
|
||||||
|
<Fragment slot="after-content">
|
||||||
<div class="mx-auto max-w-2xl px-4 sm:px-6">
|
<div class="mx-auto max-w-2xl px-4 sm:px-6">
|
||||||
<TwikooComments envId="http://47.108.235.131:40063/" path={commentPath} />
|
<TwikooComments envId="http://47.108.235.131:40063/" path={commentPath} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</Layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user