Skip to content

Commit 3ab36ad

Browse files
fix: inject keywords to meta tags
1 parent 61a2221 commit 3ab36ad

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/.vitepress/config.mts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export default withMermaid(defineConfig({
125125

126126
transformPageData(pageData) {
127127
const head = pageData.frontmatter.head ??= []
128+
129+
// Inject canonical URL if not already defined in frontmatter
128130
const hasCanonical = head.some(
129131
([tag, attrs]) => tag === 'link' && attrs?.rel === 'canonical'
130132
)
@@ -134,6 +136,12 @@ export default withMermaid(defineConfig({
134136
.replace(/\.md$/, '')
135137
head.push(['link', { rel: 'canonical', href: canonicalUrl }])
136138
}
139+
140+
// Inject frontmatter keywords as a meta tag (VitePress doesn't do this natively)
141+
const keywords = pageData.frontmatter.keywords
142+
if (keywords) {
143+
head.push(['meta', { name: 'keywords', content: keywords }])
144+
}
137145
},
138146

139147
themeConfig: {

0 commit comments

Comments
 (0)