* Fix: Astro generates empty .-index.bundle.js

https://github.com/withastro/astro/issues/5400

* Create loud-penguins-tickle.md
This commit is contained in:
impcyber 2022-11-15 23:26:37 +03:00 committed by GitHub
parent a93aa4ef3f
commit 3c5cb69488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix: https://github.com/withastro/astro/issues/5400

View file

@ -25,6 +25,7 @@ export function shortHashedName(id: string, ctx: { getModuleInfo: GetModuleInfo
export function createSlugger(settings: AstroSettings) {
const pagesDir = viteID(new URL('./pages', settings.config.srcDir));
const indexPage = viteID(new URL("./pages/index", settings.config.srcDir));
const map = new Map<string, Map<string, number>>();
const sep = '-';
return function (id: string, ctx: { getModuleInfo: GetModuleInfo }): string {
@ -33,7 +34,7 @@ export function createSlugger(settings: AstroSettings) {
.map(([page]) => page.id)
.sort()
.join('-');
const firstParentId = parents[0]?.[0].id || 'index';
const firstParentId = parents[0]?.[0].id || indexPage;
// Use the last two segments, for ex /docs/index
let dir = firstParentId;