File tree Expand file tree Collapse file tree
vue-press/src/.vuepress/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,10 +102,12 @@ export const createNamespaceRouteMap = (
102102 . relative ( repoRoot , targetPath )
103103 . split ( path . sep )
104104 . join ( '/' ) ;
105+ // A directory with its own README publishes there; otherwise it aggregates into the
106+ // linking wrapper's own page.
105107 const targetRoute =
106108 exact [ targetSource ] ??
107109 ( existsSync ( targetPath ) && statSync ( targetPath ) . isDirectory ( )
108- ? wrapperRoute
110+ ? ( exact [ ` ${ targetSource } /README.md` ] ?? wrapperRoute )
109111 : undefined ) ;
110112 // Missing files remain visible to link validation instead of falling back to a parent page.
111113 if ( ! targetRoute ) {
@@ -166,6 +168,17 @@ export const rewriteNamespaceHref = (
166168 if ( aliasedRoute ) {
167169 return `${ normalizedBase } ${ aliasedRoute } ${ suffix } ` ;
168170 }
171+ // Hand-authored absolute links to a real page are missing only the deployment base —
172+ // VuePress treats a base-less absolute path as external regardless of its extension.
173+ const knownRoute = [
174+ publicPath ,
175+ `${ publicPath } .html` ,
176+ publicPath . replace ( / \. m d $ / , '.html' ) ,
177+ `${ publicPath } /` ,
178+ ] . find ( ( candidate ) => routeMaps . sourceByRoute [ candidate ] !== undefined ) ;
179+ if ( knownRoute ) {
180+ return `${ normalizedBase } ${ knownRoute } ${ suffix } ` ;
181+ }
169182 const namespaceMatch = pathname . match ( / (?: ^ | \/ ) ( p a c k a g e s | c o o k b o o k s ) \/ ( .+ ) $ / ) ;
170183 // Ordinary relative and external links are outside this plugin's namespace contract.
171184 if ( ! namespaceMatch ) {
You can’t perform that action at this time.
0 commit comments