Skip to content

Commit

Permalink
fix: check correct flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Apr 27, 2023
1 parent 5b8d2b2 commit 4b18f42
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/astro/src/content/vite-plugin-content-assets.ts
Expand Up @@ -33,21 +33,19 @@ export function astroContentAssetPropagationPlugin({
enforce: 'pre',
async resolveId(id, importer, opts) {
if (hasContentFlag(id, CONTENT_RENDER_FLAG)) {
const resolvedBase = await this.resolve(id.split('?')[0], importer, {
skipSelf: true,
...opts,
});
if (!resolvedBase) return;
const base = resolvedBase.id;
const base = id.split('?')[0];

for (const { extensions, handlePropagation = true } of settings.contentEntryTypes) {
if (handlePropagation && extensions.includes(extname(base))) {
return `${base}?${PROPAGATED_ASSET_FLAG}`;
return this.resolve(`${base}?${PROPAGATED_ASSET_FLAG}`, importer, {
skipSelf: true,
...opts,
});
}
}
// Resolve to the base id (no content flags)
// if Astro doesn't need to handle propagation.
return base;
return this.resolve(base, importer, { skipSelf: true, ...opts });
}
},
configureServer(server) {
Expand All @@ -56,7 +54,7 @@ export function astroContentAssetPropagationPlugin({
}
},
async transform(_, id, options) {
if (hasContentFlag(id, CONTENT_RENDER_FLAG)) {
if (hasContentFlag(id, PROPAGATED_ASSET_FLAG)) {
const basePath = id.split('?')[0];
let stringifiedLinks: string, stringifiedStyles: string, stringifiedScripts: string;

Expand Down

0 comments on commit 4b18f42

Please sign in to comment.