Skip to content

Commit 76e05c2

Browse files
fix: canonical links (#214)
* fix: canonical links * fix: transform page data
1 parent 419827f commit 76e05c2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/.vitepress/config.mts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ export default withMermaid(defineConfig({
109109
['meta', { name: 'keywords', content: 'plane, api, self-hosting, project management, developer documentation, kubernetes, docker, rest api, webhooks, plane api' }],
110110
['meta', { name: 'theme-color', content: '#3b82f6' }],
111111

112-
// SEO: Canonical URL
113-
['link', { rel: 'canonical', href: 'https://developers.plane.so' }],
114-
115112
// Open Graph meta tags
116113
['meta', { property: 'og:type', content: 'website' }],
117114
['meta', { property: 'og:title', content: 'Developer documentation | Plane' }],
@@ -126,6 +123,19 @@ export default withMermaid(defineConfig({
126123
['meta', { name: 'twitter:image', content: 'https://media.docs.plane.so/logo/og-docs.webp' }],
127124
],
128125

126+
transformPageData(pageData) {
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+
}
137+
},
138+
129139
themeConfig: {
130140
siteTitle: false,
131141
logo: {

0 commit comments

Comments
 (0)