diff --git a/.changeset/flat-papayas-invite.md b/.changeset/flat-papayas-invite.md new file mode 100644 index 000000000000..c8b1193d7662 --- /dev/null +++ b/.changeset/flat-papayas-invite.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Allow astro to be installed underneath a folder with leading slashes diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts index ecda537e2094..6ab920c4d84e 100644 --- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts +++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts @@ -21,6 +21,7 @@ import { type ContentLookupMap, type ContentPaths, } from './utils.js'; +import { appendForwardSlash } from '../core/path.js'; interface AstroContentVirtualModPluginParams { settings: AstroSettings; @@ -209,5 +210,6 @@ const UnexpectedLookupMapError = new AstroError({ function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] { const extGlob = getExtGlob(exts); - return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`]; + const contentDir = appendForwardSlash(relContentDir); + return [`${contentDir}**/*${extGlob}`, `!${contentDir}_*/**${extGlob}`, `!${contentDir}_*${extGlob}`]; }