File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
packages/docs/.vitepress/config Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,25 @@ if (process.env.NETLIFY) {
1010 console . log ( 'Netlify build' , process . env . CONTEXT )
1111}
1212
13+ const rControl = / [ \u0000 - \u001f ] / g
14+ const rSpecial = / [ \s ~ ` ! @ # $ % ^ & * ( ) \- _ + = [ \] { } | \\ ; : " ' “ ” ‘ ’ < > , . ? / ] + / g
15+ const rCombining = / [ \u0300 - \u036F ] / g
16+
17+ /**
18+ * Default slugification function
19+ */
20+ export const slugify = ( str : string ) : string =>
21+ str
22+ . normalize ( 'NFKD' )
23+ // Remove accents
24+ . replace ( rCombining , '' )
25+ // Remove control characters
26+ . replace ( rControl , '' )
27+ // Replace special characters
28+ . replace ( rSpecial , '-' )
29+ // ensure it doesn't start with a number
30+ . replace ( / ^ ( \d ) / , '_$1' )
31+
1332const productionHead : HeadConfig [ ] = [
1433 [
1534 'script' ,
@@ -37,7 +56,7 @@ export const sharedConfig = defineConfig({
3756 } ,
3857
3958 anchor : {
40- slugify : s => s . replace ( / \s / g , '-' ) ,
59+ slugify,
4160 } ,
4261 } ,
4362
You can’t perform that action at this time.
0 commit comments