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:
@@ -13,9 +13,7 @@ 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",
|
||||||
@@ -24,49 +22,42 @@ const structuredData = {
|
|||||||
image: ogImage,
|
image: ogImage,
|
||||||
...(pubDatetime && { datePublished: pubDatetime.toISOString() }),
|
...(pubDatetime && { datePublished: pubDatetime.toISOString() }),
|
||||||
...(modDatetime && { dateModified: modDatetime.toISOString() }),
|
...(modDatetime && { dateModified: modDatetime.toISOString() }),
|
||||||
author: [
|
author: [{ "@type": "Person", name: site.author, ...(site.profile && { url: site.profile }) }],
|
||||||
{
|
|
||||||
"@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()} />}
|
||||||
pubDatetime && (
|
{modDatetime && <meta property="article:modified_time" content={modDatetime.toISOString()} />}
|
||||||
<meta
|
<script type="application/ld+json" is:inline set:html={JSON.stringify(structuredData)} />
|
||||||
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>
|
</Fragment>
|
||||||
|
|
||||||
<!-- 文章内容(保持原有结构) -->
|
<!-- 文章主体 -->
|
||||||
<article class="prose prose-lg max-w-3xl mx-auto px-4">
|
<article class="prose prose-lg max-w-3xl mx-auto px-4">
|
||||||
<slot />
|
<slot />
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<!-- 👇 评论区域:应用与文章相同的宽度和居中样式 -->
|
<!-- 评论区域:宽度对齐、居中、清除浮动 -->
|
||||||
<div class="max-w-3xl mx-auto px-4 mt-8 w-full">
|
<div class="comment-wrapper max-w-3xl mx-auto px-4 mt-8 w-full" style="clear: both;">
|
||||||
<Comment />
|
<Comment />
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
|
<!-- 全局样式修复黑线问题(仅针对评论区域) -->
|
||||||
|
<style is:global>
|
||||||
|
.comment-wrapper a,
|
||||||
|
.comment-wrapper button,
|
||||||
|
.comment-wrapper .tk-submit {
|
||||||
|
text-decoration: none !important;
|
||||||
|
border-bottom: none !important;
|
||||||
|
box-shadow: none !important; /* 有时黑线是 box-shadow 造成的 */
|
||||||
|
}
|
||||||
|
/* 如果评论框内部输入框出现黑线 */
|
||||||
|
.comment-wrapper input,
|
||||||
|
.comment-wrapper textarea {
|
||||||
|
border: 1px solid #ccc; /* 保持边框但去掉下划线风格 */
|
||||||
|
border-bottom: 1px solid #ccc !important; /* 保证底部不是黑色 */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user