diff --git a/.changeset/selfish-scissors-repeat.md b/.changeset/selfish-scissors-repeat.md new file mode 100644 index 000000000..8568a25a8 --- /dev/null +++ b/.changeset/selfish-scissors-repeat.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes the output when using the experimental-static-build flag diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index fd73e0d93..3c08f4f61 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -101,6 +101,7 @@ class AstroBuilder { astroConfig: this.config, logging: this.logging, origin: this.origin, + pageNames, routeCache: this.routeCache, viteConfig: this.viteConfig, }); diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index d37fb48ac..c424ec92d 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -25,10 +25,16 @@ export interface StaticBuildOptions { astroConfig: AstroConfig; logging: LogOptions; origin: string; + pageNames: string[]; routeCache: RouteCache; viteConfig: ViteConfigWithSSR; } +function addPageName(pathname: string, opts: StaticBuildOptions): void { + const pathrepl = opts.astroConfig.buildOptions.pageUrlFormat === 'directory' ? '/index.html' : pathname === '/' ? 'index.html' : '.html'; + opts.pageNames.push(pathname.replace(/\/?$/, pathrepl).replace(/^\//, '')); +} + export async function staticBuild(opts: StaticBuildOptions) { const { allPages, astroConfig } = opts; @@ -198,9 +204,12 @@ interface GeneratePathOptions { } async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: GeneratePathOptions) { - const { astroConfig, logging, origin, routeCache } = opts; + const { astroConfig, logging, origin, pageNames, routeCache } = opts; const { Component, internals, linkIds, pageData } = gopts; + // This adds the page name to the array so it can be shown as part of stats. + addPageName(pathname, opts); + const [renderers, mod] = pageData.preload; try {