File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,28 @@ const baseURL = import.meta.env.BASE_URL ?? '/'
1616
1717const normalizeURLPath = url => ( url ? join ( baseURL , url ) : undefined )
1818
19+ const removeBaseURL = url => {
20+ if ( typeof url !== 'string' ) {
21+ return undefined
22+ }
23+
24+ if ( url . startsWith ( baseURL ) ) {
25+ const result = url . slice ( baseURL . length )
26+ return result === '' ? '/' : result
27+ }
28+
29+ const baseURLWithoutSlash = baseURL . endsWith ( '/' )
30+ ? baseURL . slice ( 0 , - 1 )
31+ : baseURL
32+
33+ if ( url . startsWith ( baseURLWithoutSlash ) ) {
34+ const result = url . slice ( baseURLWithoutSlash . length )
35+ return result === '' ? '/' : result
36+ }
37+
38+ return undefined
39+ }
40+
1941// @ts -expect-error injected by vite
2042import { routes } from '~routes'
2143
@@ -60,6 +82,8 @@ export const prerender = async ({ url }) => {
6082
6183 return {
6284 html,
63- links : new Set ( [ ...( discoveredLinks ?? [ ] ) ] ) ,
85+ links : new Set (
86+ [ ...discoveredLinks ] . map ( d => removeBaseURL ( d ) ) . filter ( Boolean )
87+ ) ,
6488 }
6589}
You can’t perform that action at this time.
0 commit comments