File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1- import { ensureLeadingSlash , resolveLocalePath } from '@vuepress/shared'
1+ import {
2+ ensureLeadingSlash ,
3+ inferRoutePath ,
4+ resolveLocalePath ,
5+ } from '@vuepress/shared'
26import type { App } from '../types/index.js'
37
48/**
@@ -23,9 +27,7 @@ export const inferPagePath = ({
2327
2428 // infer page route path from file path
2529 // foo/bar.md -> /foo/bar.html
26- const pathInferred = ensureLeadingSlash ( filePathRelative )
27- . replace ( / \. m d $ / , '.html' )
28- . replace ( / \/ ( R E A D M E | i n d e x ) .h t m l $ / i, '/' )
30+ const pathInferred = ensureLeadingSlash ( inferRoutePath ( filePathRelative ) )
2931
3032 // resolve page locale path
3133 const pathLocale = resolveLocalePath ( app . siteData . locales , pathInferred )
Original file line number Diff line number Diff line change 11/**
2- * Infer route path according to the given (markdown file) path
2+ * Infer route path of the given raw path
33 */
4- export const inferRoutePath = ( path : string ) : string => {
5- // if the pathname is empty or ends with `/`, return as is
6- if ( ! path || path . endsWith ( '/' ) ) return path
4+ export const inferRoutePath = ( rawPath : string ) : string => {
5+ // if the raw path is empty or ends with `/`, return as is
6+ if ( ! rawPath || rawPath . endsWith ( '/' ) ) return rawPath
77
88 // convert README.md to index.html
9- let routePath = path . replace ( / ( ^ | \/ ) R E A D M E .m d $ / i, '$1index.html' )
9+ let routePath = rawPath . replace ( / ( ^ | \/ ) R E A D M E .m d $ / i, '$1index.html' )
1010
1111 // convert /foo/bar.md to /foo/bar.html
1212 if ( routePath . endsWith ( '.md' ) ) {
You can’t perform that action at this time.
0 commit comments