Skip to content

Commit

Permalink
feat: get markdoc contents
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Feb 16, 2023
1 parent 6f50068 commit 83bfe44
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/integrations/markdoc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AstroIntegration } from 'astro';
import type { InlineConfig } from 'vite';

export default function markdoc(partialOptions: {} = {}): AstroIntegration {
return {
Expand All @@ -7,6 +8,19 @@ export default function markdoc(partialOptions: {} = {}): AstroIntegration {
'astro:config:setup': async ({ updateConfig, config, addPageExtension, command }: any) => {
addPageExtension('.mdoc');
console.log('Markdoc working!');

const viteConfig: InlineConfig = {
plugins: [
{
name: '@astrojs/markdoc',
async transform(code, id) {
if (!id.endsWith('.mdoc')) return;
return `export const body = ${JSON.stringify(code)}`;
},
},
],
};
updateConfig({ vite: viteConfig });
},
},
};
Expand Down

0 comments on commit 83bfe44

Please sign in to comment.