@@ -15,6 +15,7 @@ type Props = {
1515 pubDatetime? : Date ;
1616 modDatetime? : Date | null ;
1717 scrollSmooth? : boolean ;
18+ noindex? : boolean ;
1819};
1920
2021const {
@@ -27,25 +28,40 @@ const {
2728 pubDatetime,
2829 modDatetime,
2930 scrollSmooth = false ,
31+ noindex = false ,
3032} = Astro .props ;
3133
3234const socialImageURL = new URL (ogImage , Astro .url );
33-
34- const structuredData = {
35- " @context" : " https://schema.org" ,
36- " @type" : " BlogPosting" ,
37- headline: ` ${title } ` ,
38- image: ` ${socialImageURL } ` ,
39- datePublished: ` ${pubDatetime ?.toISOString ()} ` ,
40- ... (modDatetime && { dateModified: modDatetime .toISOString () }),
41- author: [
42- {
43- " @type" : " Person" ,
44- name: ` ${author } ` ,
45- ... (profile && { url: profile }),
46- },
47- ],
48- };
35+ const isPost = !! pubDatetime ;
36+ const ogLocale = (SITE .lang as string ) === " de" ? " de_DE" : " en_US" ;
37+
38+ const structuredData = isPost
39+ ? {
40+ " @context" : " https://schema.org" ,
41+ " @type" : " BlogPosting" ,
42+ mainEntityOfPage: {
43+ " @type" : " WebPage" ,
44+ " @id" : canonicalURL .toString (),
45+ },
46+ headline: title ,
47+ description ,
48+ image: socialImageURL .toString (),
49+ datePublished: pubDatetime ! .toISOString (),
50+ ... (modDatetime && { dateModified: modDatetime .toISOString () }),
51+ author: [
52+ {
53+ " @type" : " Person" ,
54+ name: author ,
55+ ... (profile && { url: profile }),
56+ },
57+ ],
58+ publisher: {
59+ " @type" : " Person" ,
60+ name: SITE .author ,
61+ url: SITE .profile ,
62+ },
63+ }
64+ : null ;
4965---
5066
5167<!doctype html >
@@ -72,9 +88,13 @@ const structuredData = {
7288 <meta name =" title" content ={ title } />
7389 <meta name =" description" content ={ description } />
7490 <meta name =" author" content ={ author } />
91+ { noindex && <meta name = " robots" content = " noindex, nofollow" />}
7592 <link rel =" sitemap" href =" /sitemap-index.xml" />
7693
7794 <!-- Open Graph / Facebook -->
95+ <meta property =" og:type" content ={ isPost ? " article" : " website" } />
96+ <meta property =" og:site_name" content ={ SITE .title } />
97+ <meta property =" og:locale" content ={ ogLocale } />
7898 <meta property =" og:title" content ={ title } />
7999 <meta property =" og:description" content ={ description } />
80100 <meta property =" og:url" content ={ canonicalURL } />
@@ -105,12 +125,16 @@ const structuredData = {
105125 <meta property =" twitter:description" content ={ description } />
106126 <meta property =" twitter:image" content ={ socialImageURL } />
107127
108- <!-- Google JSON-LD Structured data -->
109- <script
110- type =" application/ld+json"
111- is:inline
112- set:html ={ JSON .stringify (structuredData )}
113- />
128+ <!-- Google JSON-LD Structured data (only for blog posts) -->
129+ {
130+ structuredData && (
131+ <script
132+ type = " application/ld+json"
133+ is :inline
134+ set :html = { JSON .stringify (structuredData )}
135+ />
136+ )
137+ }
114138
115139 <!-- Enable RSS feed auto-discovery -->
116140 <!-- https://docs.astro.build/en/recipes/rss/#enabling-rss-feed-auto-discovery -->
@@ -121,7 +145,7 @@ const structuredData = {
121145 href ={ new URL (" rss.xml" , Astro .site )}
122146 />
123147
124- <meta name =" theme-color" content =" " />
148+ <meta name =" theme-color" content =" #fdfdfd " />
125149
126150 {
127151 // If PUBLIC_GOOGLE_SITE_VERIFICATION is set in the environment variable,
0 commit comments