File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,25 @@ import {
1111 releases ,
1212} from './meta'
1313
14+ const rControl = / [ \u0000 - \u001f ] / g
15+ const rSpecial = / [ \s ~ ` ! @ # $ % ^ & * ( ) \- _ + = [ \] { } | \\ ; : " ' “ ” ‘ ’ < > , . ? / ] + / g
16+ const rCombining = / [ \u0300 - \u036F ] / g
17+
18+ /**
19+ * Default slugification function
20+ */
21+ export const slugify = ( str : string ) : string =>
22+ str
23+ . normalize ( 'NFKD' )
24+ // Remove accents
25+ . replace ( rCombining , '' )
26+ // Remove control characters
27+ . replace ( rControl , '' )
28+ // Replace special characters
29+ . replace ( rSpecial , '-' )
30+ // ensure it doesn't start with a number
31+ . replace ( / ^ ( \d ) / , '_$1' )
32+
1433export default defineConfig ( {
1534 lang : 'en-US' ,
1635 title : headTitle ,
@@ -28,7 +47,7 @@ export default defineConfig({
2847 } ,
2948
3049 anchor : {
31- slugify : ( s : string ) => s . replace ( / \s + / g , '-' ) ,
50+ slugify,
3251 } ,
3352 } ,
3453
You can’t perform that action at this time.
0 commit comments