[ci] format
This commit is contained in:
parent
cd154e447b
commit
b680c3eb97
3 changed files with 60 additions and 48 deletions
|
@ -244,7 +244,13 @@ function addPageName(pathname: string, opts: StaticBuildOptions): void {
|
||||||
opts.pageNames.push(pathname.replace(/^\//, ''));
|
opts.pageNames.push(pathname.replace(/^\//, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrlForPath(pathname: string, base: string, origin: string, format: 'directory' | 'file', routeType: RouteType): URL {
|
function getUrlForPath(
|
||||||
|
pathname: string,
|
||||||
|
base: string,
|
||||||
|
origin: string,
|
||||||
|
format: 'directory' | 'file',
|
||||||
|
routeType: RouteType
|
||||||
|
): URL {
|
||||||
/**
|
/**
|
||||||
* Examples:
|
* Examples:
|
||||||
* pathname: /, /foo
|
* pathname: /, /foo
|
||||||
|
@ -252,13 +258,14 @@ function getUrlForPath(pathname: string, base: string, origin: string, format: '
|
||||||
*/
|
*/
|
||||||
const ending = format === 'directory' ? '/' : '.html';
|
const ending = format === 'directory' ? '/' : '.html';
|
||||||
let buildPathname: string;
|
let buildPathname: string;
|
||||||
if(pathname === '/' || pathname === '') {
|
if (pathname === '/' || pathname === '') {
|
||||||
buildPathname = base;
|
buildPathname = base;
|
||||||
} else if(routeType === 'endpoint') {
|
} else if (routeType === 'endpoint') {
|
||||||
const buildPathRelative = removeLeadingForwardSlash(pathname);
|
const buildPathRelative = removeLeadingForwardSlash(pathname);
|
||||||
buildPathname = base + buildPathRelative;
|
buildPathname = base + buildPathRelative;
|
||||||
} else {
|
} else {
|
||||||
const buildPathRelative = removeTrailingForwardSlash(removeLeadingForwardSlash(pathname)) + ending;
|
const buildPathRelative =
|
||||||
|
removeTrailingForwardSlash(removeLeadingForwardSlash(pathname)) + ending;
|
||||||
buildPathname = base + buildPathRelative;
|
buildPathname = base + buildPathRelative;
|
||||||
}
|
}
|
||||||
const url = new URL(buildPathname, origin);
|
const url = new URL(buildPathname, origin);
|
||||||
|
@ -312,8 +319,13 @@ async function generatePath(
|
||||||
}
|
}
|
||||||
|
|
||||||
const ssr = opts.astroConfig.output === 'server';
|
const ssr = opts.astroConfig.output === 'server';
|
||||||
const url = getUrlForPath(pathname, opts.astroConfig.base, origin,
|
const url = getUrlForPath(
|
||||||
opts.astroConfig.build.format, pageData.route.type);
|
pathname,
|
||||||
|
opts.astroConfig.base,
|
||||||
|
origin,
|
||||||
|
opts.astroConfig.build.format,
|
||||||
|
pageData.route.type
|
||||||
|
);
|
||||||
const options: RenderOptions = {
|
const options: RenderOptions = {
|
||||||
adapterName: undefined,
|
adapterName: undefined,
|
||||||
links,
|
links,
|
||||||
|
|
Loading…
Reference in a new issue