Skip to content

Commit e5df1d4

Browse files
committed
fix: docs
1 parent 3b1a54b commit e5df1d4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs-v2/nuxt.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,27 @@ export default theme({
1717
async: true,
1818
}
1919
]
20+
},
21+
hooks: {
22+
'content:file:beforeInsert': (document) => {
23+
if (document.extension === '.md' && document.dir) {
24+
const base = 'https://restify.binarcode.com';
25+
const path = document.dir.replace('/content', '') + '/' + document.slug;
26+
const canonicalUrl = base + path.replace(/\/+/g, '/') + '/';
27+
28+
if (!document.head) {
29+
document.head = {};
30+
}
31+
32+
if (!document.head.link) {
33+
document.head.link = [];
34+
}
35+
36+
document.head.link.push({
37+
rel: 'canonical',
38+
href: canonicalUrl
39+
});
40+
}
41+
}
2042
}
2143
});

0 commit comments

Comments
 (0)