File tree Expand file tree Collapse file tree 1 file changed +1
-20
lines changed
Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change 1313 if ( typeof window === 'undefined' ) {
1414 return ;
1515 }
16- // Called by getPageSlug() to decode slightly different permutations of a path.
17- function normalizePathname ( pathname ) {
18- let path = decodeURIComponent ( pathname || '/' ) ;
19-
20- // Support browsing the statically-built site using *.html files.
21- path = path . replace ( / i n d e x \. h t m l $ / i, '' ) ;
22- // Collapse any accidental duplicate slashes.
23- path = path . replace ( / \/ + / g, '/' ) ;
24-
25- if ( path . length > 1 && path . endsWith ( '/' ) ) {
26- path = path . slice ( 0 , - 1 ) ;
27- }
28-
29- return path || '/' ;
30- }
31- // Called by getPageSlug() after normalizePathname() to build and return the slug.
3216 function buildSlugFromPath ( pathname ) {
3317 if ( ! pathname || pathname === '/' ) {
3418 return 'index' ;
5337 if ( segments [ 1 ] === 'pages' || segments [ 1 ] === 'categories' ) {
5438 segments . splice ( 0 , 2 ) ;
5539 }
56- } else if ( segments [ 0 ] === 'ai-pages' || segments [ 0 ] === 'ai-categories' ) {
57- segments . splice ( 0 , 1 ) ;
5840 }
5941
6042 const slug = segments
7153 }
7254
7355 function getPageSlug ( ) {
74- const normalized = normalizePathname ( window . location . pathname ) ;
75- return buildSlugFromPath ( normalized ) ;
56+ return buildSlugFromPath ( window . location . pathname ) ;
7657 }
7758
7859 function getMarkdownUrl ( slug ) {
You can’t perform that action at this time.
0 commit comments