From 37426a10bc7e9e872dcfdaac978112f6f09fde8d Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Thu, 9 Feb 2023 12:26:21 -0500 Subject: [PATCH] fix: markdoc.config loading --- packages/integrations/markdoc/src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/integrations/markdoc/src/index.ts b/packages/integrations/markdoc/src/index.ts index 4062892f9..516980735 100644 --- a/packages/integrations/markdoc/src/index.ts +++ b/packages/integrations/markdoc/src/index.ts @@ -24,7 +24,7 @@ export default function markdoc(partialOptions: {} = {}): AstroIntegration { 'astro:config:setup': async ({ updateConfig, config, addContentEntryType, command }: any) => { addContentEntryType(contentEntryType); console.log('Markdoc working!'); - const markdocConfigUrl = new URL('./markdoc.config.ts', config.srcDir); + const markdocConfigUrl = new URL('./markdoc.config', config.srcDir); const viteConfig: InlineConfig = { plugins: [ @@ -35,13 +35,15 @@ export default function markdoc(partialOptions: {} = {}): AstroIntegration { return `import { jsx as h } from 'astro/jsx-runtime';\nimport { Markdoc } from '@astrojs/markdoc';\nimport { Renderer } from '@astrojs/markdoc/components';\nexport const body = ${JSON.stringify( code )};\nexport function getParsed() { return Markdoc.parse(body); }\nexport async function getTransformed(inlineConfig) { -let config = inlineConfig ?? {}; +let config = inlineConfig; if (!config) { try { const importedConfig = await import(${JSON.stringify(markdocConfigUrl.pathname)}); - console.log({ importedConfig }) + console.log({importedConfig}) config = importedConfig.default.transform; - } catch {} + } catch { + config = {}; + } } return Markdoc.transform(getParsed(), config) }\nexport async function Content ({ transformConfig, components }) { return h(Renderer, { content: await getTransformed(transformConfig), components }); }\nContent[Symbol.for('astro.needsHeadRendering')] = true;`; },