@mdxvac/remark-astro-rawmdx
remark plugin to add the raw markdown content to the frontmatter of your Astro MDX files (property rawmdx
).
MDX Vacuum is a set of plugins allowing you to define an Astro
Have a look at the other mdxvac
plugins.
Content
What is this?
This package is a remark
plugin to add the raw markdown content to the frontmatter of your MDX files in the context of Astro site generation.
When should I use this?
Astro MDX files do not carry the raw MDX content anymore, once you import them. With this plugin you can access the raw content in the frontmatter mdx
property.
Use this plugin, if you want to have access to the raw MDX content while generating your Astro pages.
Install
This package is ESM only.
In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm
:
npm install -D @mdxvac/remark-astro-rawmdx
Use
In your astro.config.mjs
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import rawMdx from '@mdxvac/remark-astro-rawmdx';
// ^^^
// https://astro.build/config
export default defineConfig({
integrations: [mdx()],
markdown: {
remarkPlugins: [rawMdx],
// ^^^
extendDefaultPlugins: true,
},
});
This uses the default options, where the name of the property on the frontmatter is rawmdx
.
Options
If you want to use a different name for the property, you can specify it in the plugin's property
option like so:
remarkPlugins: [[rawMdx, {property: "raw"}]],