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"; - + - + - + - + - + + +