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 {
11
11
releases ,
12
12
} from './meta'
13
13
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
+
14
33
export default defineConfig ( {
15
34
lang : 'en-US' ,
16
35
title : headTitle ,
@@ -28,7 +47,7 @@ export default defineConfig({
28
47
} ,
29
48
30
49
anchor : {
31
- slugify : ( s : string ) => s . replace ( / \s + / g , '-' ) ,
50
+ slugify,
32
51
} ,
33
52
} ,
34
53
You can’t perform that action at this time.
0 commit comments