import { siteDataRef } from './data' ; import { inBrowser , EXTERNAL_URL_RE } from '../shared' ; export { inBrowser } ; /**
 * Join two paths by resolving the slash collision.
 */ export function joinPath ( base , path ) { return `${ base }${ path }` . replace ( /\/+/g , '/' ) ; } export function withBase ( path ) { return EXTERNAL_URL_RE . test ( path ) ? path : joinPath ( siteDataRef . value . base , path ) ; } /**
 * Converts a url path to the corresponding js chunk filename.
 */ export function pathToFile ( path ) { let pagePath = path . replace ( /\.html$/ , '' ) ; pagePath = decodeURIComponent ( pagePath ) ; if ( pagePath . endsWith ( '/' ) ) { pagePath += 'index' ; } if ( import . meta . env . DEV ) { pagePath += `.md?t=${ Date . now ( ) }` ; } else { if ( inBrowser ) { const base = import . meta . env . BASE_URL ; pagePath = pagePath . slice ( base . length ) . replace ( /\//g , '_' ) + '.md' ; const pageHash = __VP_HASH_MAP__ [ pagePath . toLowerCase ( ) ] ; pagePath = `${ base }assets/${ pagePath }.${ pageHash }.js` ; } else { pagePath = `./${ pagePath . slice ( 1 ) . replace ( /\//g , '_' ) }.md.js` ; } } return pagePath ; }