Files
website/node_modules/@astrojs/starlight/utils/base.ts
2024-05-06 17:15:30 -04:00

16 lines
529 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { stripLeadingSlash, stripTrailingSlash } from './path';
const base = stripTrailingSlash(import.meta.env.BASE_URL);
/** Get the a root-relative URL path with the sites `base` prefixed. */
export function pathWithBase(path: string) {
path = stripLeadingSlash(path);
return path ? base + '/' + path : base + '/';
}
/** Get the a root-relative file URL path with the sites `base` prefixed. */
export function fileWithBase(path: string) {
path = stripLeadingSlash(path);
return path ? base + '/' + path : base;
}