feat: get markdoc contents
This commit is contained in:
parent
e5d009a3cf
commit
5315c50709
1 changed files with 14 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
import type { AstroIntegration } from 'astro';
|
import type { AstroIntegration } from 'astro';
|
||||||
|
import type { InlineConfig } from 'vite';
|
||||||
|
|
||||||
export default function markdoc(partialOptions: {} = {}): AstroIntegration {
|
export default function markdoc(partialOptions: {} = {}): AstroIntegration {
|
||||||
return {
|
return {
|
||||||
|
@ -7,6 +8,19 @@ export default function markdoc(partialOptions: {} = {}): AstroIntegration {
|
||||||
'astro:config:setup': async ({ updateConfig, config, addPageExtension, command }: any) => {
|
'astro:config:setup': async ({ updateConfig, config, addPageExtension, command }: any) => {
|
||||||
addPageExtension('.mdoc');
|
addPageExtension('.mdoc');
|
||||||
console.log('Markdoc working!');
|
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 });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue