fix: experimentalAssetsConfig missing

This commit is contained in:
bholmesdev 2023-06-08 11:10:10 -04:00 committed by bholmesdev
parent b46b0ec64c
commit 77971eec8e

View file

@ -22,9 +22,22 @@ export function vitePluginMarkdocConfig({ astroConfig }: { astroConfig: AstroCon
// TODO: invalidate on change
const markdocConfigResult = await loadMarkdocConfig(astroConfig);
// Only add `astro/assets` import when `experimental.assets` is enabled. Would throw without this check!
const injectAssetsConfig = astroConfig.experimental.assets;
if (!markdocConfigResult) {
return `export default {}`;
return `${
injectAssetsConfig
? `import { experimentalAssetsConfig } from '@astrojs/markdoc/experimental-assets-config';\n`
: ''
}export async function getConfig(configOverrides = {}) { return ${
injectAssetsConfig
? '{ ...experimentalAssetsConfig, ...configOverrides }'
: 'configOverrides'
} }
export function getConfigSync() { return ${
injectAssetsConfig ? 'experimentalAssetsConfig' : '{}'
} }`;
}
const { config: unresolvedConfig, fileUrl } = markdocConfigResult;
const config = await setupConfig(unresolvedConfig);