Skip to content

Commit 83bfe44

Browse files
committed
feat: get markdoc contents
1 parent 6f50068 commit 83bfe44

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • packages/integrations/markdoc/src

packages/integrations/markdoc/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AstroIntegration } from 'astro';
2+
import type { InlineConfig } from 'vite';
23

34
export default function markdoc(partialOptions: {} = {}): AstroIntegration {
45
return {
@@ -7,6 +8,19 @@ export default function markdoc(partialOptions: {} = {}): AstroIntegration {
78
'astro:config:setup': async ({ updateConfig, config, addPageExtension, command }: any) => {
89
addPageExtension('.mdoc');
910
console.log('Markdoc working!');
11+
12+
const viteConfig: InlineConfig = {
13+
plugins: [
14+
{
15+
name: '@astrojs/markdoc',
16+
async transform(code, id) {
17+
if (!id.endsWith('.mdoc')) return;
18+
return `export const body = ${JSON.stringify(code)}`;
19+
},
20+
},
21+
],
22+
};
23+
updateConfig({ vite: viteConfig });
1024
},
1125
},
1226
};

0 commit comments

Comments
 (0)