diff --git a/src/components/Head.astro b/src/components/Head.astro
index f8c8fd2..ebe96fc 100644
--- a/src/components/Head.astro
+++ b/src/components/Head.astro
@@ -3,8 +3,14 @@ import SITE_CONFIG from "../config";
// 当前页面的 URL 元地址
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
// 页面内容的元数据
-const { Title: title, Keywords, Description } = Astro.props;
-const { Site, Title, Subtitle, Author, Cover, DNSOptimization } = SITE_CONFIG;
+const { Title, Keywords, Description, PageCover } = Astro.props;
+const { Site, Title: SiteName, Subtitle, Author, Cover, DNSOptimization } = SITE_CONFIG;
+const WebTitle = Title || SiteName;
+const SiteCover = Site + Cover;
+const WebCover = PageCover || SiteCover;
+// Schema.org 结构化数据(JSON-LD)
+const WebSiteData = { "@context": "https://schema.org", "@type": "WebSite", name: WebTitle, url: canonicalURL, image: { "@type": "ImageObject", url: SiteCover } };
+const ArticleData = { "@context": "https://schema.org", "@type": "BlogPosting", mainEntityOfPage: { "@type": "WebPage", "@id": canonicalURL.href }, headline: WebTitle, image: [WebCover], author: { "@type": "Person", name: Author, url: Site }, publisher: { "@type": "Organization", name: SiteName, logo: { "@type": "ImageObject", url: SiteCover } } };
// 基础 样式
import "../styles/Base.less";
---
@@ -14,12 +20,12 @@ import "../styles/Base.less";
-
{title ? `${title} | ${Title}` : `${Title} - ${Subtitle}`}
+ {Title ? `${Title} | ${SiteName}` : `${SiteName} - ${Subtitle}`}
-
+
@@ -27,18 +33,20 @@ import "../styles/Base.less";
-
+
-
+
-
+
-
+
-
+
+
+
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro
index 095eb69..9ba5cc2 100644
--- a/src/layouts/Layout.astro
+++ b/src/layouts/Layout.astro
@@ -1,6 +1,6 @@
---
import { ClientRouter } from "astro:transitions";
-const { title, keywords, description, activeNav } = Astro.props;
+const { title, keywords, description, pagecover, activeNav } = Astro.props;
// Head 依赖
import Head from "../components/Head.astro";
// 顶部 Header
@@ -16,9 +16,8 @@ import "../styles/Layout.less";
---
-
-
-
+
diff --git a/src/pages/article/[...article].astro b/src/pages/article/[...article].astro
index 2115c2c..24441ba 100644
--- a/src/pages/article/[...article].astro
+++ b/src/pages/article/[...article].astro
@@ -10,6 +10,9 @@ export async function getStaticPaths() {
// 处理文章内容
type Props = CollectionEntry<"blog">;
const post: any = Astro.props;
+// 获取封面图
+import getCover from "../../utils/getCover";
+const ARTICLE_COVER: string = await getCover(post.data.cover);
// 页面 Info
import SITE_CONFIG from "../../config";
const { Site, Title, Author, Twikoo } = SITE_CONFIG;
@@ -28,7 +31,7 @@ import Comment from "../../components/Comment.astro";
import "../../styles/Article.less";
---
-
+
diff --git a/src/utils/getCover.ts b/src/utils/getCover.ts
index c0ee4df..f18b856 100644
--- a/src/utils/getCover.ts
+++ b/src/utils/getCover.ts
@@ -2,6 +2,7 @@ import path from 'path';
import _fs from 'fs';
const fs = _fs.promises;
import { fileURLToPath } from 'url';
+import SITE_INFO from '../config';
// 获取当前模块的目录路径
const __filename = fileURLToPath(import.meta.url); // 当前文件的绝对路径
const __dirname = path.dirname(__filename); // 当前文件所在的目录
@@ -61,7 +62,7 @@ const fileIter = createImageIterator(targetDir);
const getCover = async (filename: string | null | undefined) => {
if (filename) return filename;
const { value } = await fileIter.next();
- return `/assets/images/banner/${value}`
+ return SITE_INFO.Site + `/assets/images/banner/${value}`
}
export default getCover;
\ No newline at end of file