Skip to content

Commit 6abf57e

Browse files
fix: transform page data
1 parent d8a8468 commit 6abf57e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/.vitepress/config.mts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,16 @@ export default withMermaid(defineConfig({
124124
],
125125

126126
transformPageData(pageData) {
127-
const canonicalUrl = `https://developers.plane.so/${pageData.relativePath}`
128-
.replace(/index\.md$/, '')
129-
.replace(/\.md$/, '')
130-
131-
pageData.frontmatter.head ??= []
132-
pageData.frontmatter.head.push([
133-
'link',
134-
{ rel: 'canonical', href: canonicalUrl }
135-
])
127+
const head = pageData.frontmatter.head ??= []
128+
const hasCanonical = head.some(
129+
([tag, attrs]) => tag === 'link' && attrs?.rel === 'canonical'
130+
)
131+
if (!hasCanonical) {
132+
const canonicalUrl = `https://developers.plane.so/${pageData.relativePath}`
133+
.replace(/index\.md$/, '')
134+
.replace(/\.md$/, '')
135+
head.push(['link', { rel: 'canonical', href: canonicalUrl }])
136+
}
136137
},
137138

138139
themeConfig: {

0 commit comments

Comments
 (0)