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:
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import Layout from "./Layout.astro";
|
||||
import config from "@/config";
|
||||
import TwikooComments from "../components/TwikooComments.astro";
|
||||
|
||||
type Props = {
|
||||
title?: string;
|
||||
@@ -13,8 +14,9 @@ type Props = {
|
||||
|
||||
const { site } = config;
|
||||
|
||||
const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } =
|
||||
Astro.props;
|
||||
const { title, description, ogImage, canonicalURL, pubDatetime, modDatetime } = Astro.props;
|
||||
|
||||
const commentPath = canonicalURL ? new URL(canonicalURL).pathname : undefined;
|
||||
|
||||
const structuredData = {
|
||||
"@context": "https://schema.org",
|
||||
@@ -35,32 +37,25 @@ const structuredData = {
|
||||
|
||||
<Layout {title} {description} {ogImage} {canonicalURL}>
|
||||
<Fragment slot="head">
|
||||
<!-- Override og:type for article pages -->
|
||||
<meta property="og:type" content="article" />
|
||||
|
||||
{
|
||||
pubDatetime && (
|
||||
<meta
|
||||
property="article:published_time"
|
||||
content={pubDatetime.toISOString()}
|
||||
/>
|
||||
<meta property="article:published_time" content={pubDatetime.toISOString()} />
|
||||
)
|
||||
}
|
||||
{
|
||||
modDatetime && (
|
||||
<meta
|
||||
property="article:modified_time"
|
||||
content={modDatetime.toISOString()}
|
||||
/>
|
||||
<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>
|
||||
|
||||
<slot />
|
||||
|
||||
{
|
||||
commentPath && (
|
||||
<TwikooComments envId="http://47.108.235.131:40063/" path={commentPath} />
|
||||
)
|
||||
}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user