@@ -5,6 +5,10 @@ import type {Props} from "@astrojs/starlight/props";
5
5
const hasCustomOGImage = Astro .props .entry .data .head .find ((t ) =>
6
6
t .attrs .property === " og:image" ? true : false
7
7
);
8
+
9
+ // Extract frontmatter data for structured data
10
+ const { entry } = Astro .props ;
11
+ const frontmatter = entry .data ;
8
12
---
9
13
10
14
{
@@ -18,3 +22,36 @@ const hasCustomOGImage = Astro.props.entry.data.head.find((t) =>
18
22
</Default >
19
23
20
24
{ ! hasCustomOGImage && <meta property = " og:image" content = { ` ${Astro .url .href }og-image.png ` } />}
25
+
26
+ { /* Add meta tags for the new fields */ }
27
+ { frontmatter .audience && (
28
+ <meta name = " audience" content = { Array .isArray (frontmatter .audience ) ? frontmatter .audience .join (' , ' ) : frontmatter .audience } />
29
+ )}
30
+ { frontmatter .complexity && (
31
+ <meta name = " complexity" content = { frontmatter .complexity } />
32
+ )}
33
+ { frontmatter .keywords && (
34
+ <meta name = " keywords" content = { frontmatter .keywords .join (' , ' )} />
35
+ )}
36
+ { frontmatter .ai_summary && (
37
+ <meta name = " ai-summary" content = { frontmatter .ai_summary } />
38
+ )}
39
+
40
+ { /* Add JSON-LD structured data */ }
41
+ <script type =" application/ld+json" set:html ={ JSON .stringify ({
42
+ " @context" : " https://schema.org" ,
43
+ " @type" : " TechArticle" ,
44
+ " name" : frontmatter .title ,
45
+ " description" : frontmatter .description ,
46
+ " keywords" : frontmatter .keywords ?.join (' , ' ),
47
+ " audience" : Array .isArray (frontmatter .audience ) ? frontmatter .audience .join (' , ' ) : frontmatter .audience ,
48
+ " difficulty" : frontmatter .complexity ,
49
+ " abstract" : frontmatter .ai_summary ,
50
+ " url" : Astro .url .href ,
51
+ ... (frontmatter .updated && { " dateModified" : typeof frontmatter .updated === ' string' ? frontmatter .updated : frontmatter .updated .toISOString () }),
52
+ " publisher" : {
53
+ " @type" : " Organization" ,
54
+ " name" : " Kinde" ,
55
+ " url" : " https://kinde.com"
56
+ }
57
+ })} />
0 commit comments