Skip to content

Installation & Setup

Install rehype-mind-elixir using your preferred package manager.

Terminal window
npm install rehype-mind-elixir

rehype-mind-elixir supports two runtime modes.

By default, rehype-mind-elixir loads its client resources from a CDN.

No additional imports are required.

rehypeMindElixir({
useCdn: true,
});

This automatically injects:

  • Mind Elixir’s stylesheet
  • The rehype-mind-elixir client runtime

An internet connection is required at runtime.

Configure the plugin through Astro’s markdown.rehypePlugins option.

CDN mode is the default:

import { defineConfig } from 'astro/config';
import rehypeMindElixir from 'rehype-mind-elixir';
export default defineConfig({
markdown: {
rehypePlugins: [
rehypeMindElixir,
],
},
});

You can also explicitly enable it:

export default defineConfig({
markdown: {
rehypePlugins: [
[rehypeMindElixir, { useCdn: true }],
],
},
});

No manual imports are required.

You can then use mind-elixir blocks directly in Markdown:

```mind-elixir
- ZikoJS
- Core
- Addons
```

For Next.js applications using MDX, configure the plugin through @next/mdx.

next.config.mjs
import createMDX from '@next/mdx';
import rehypeMindElixir from 'rehype-mind-elixir';
const withMDX = createMDX({
options: {
rehypePlugins: [
rehypeMindElixir,
],
},
});
export default withMDX({
pageExtensions: [
'js',
'jsx',
'md',
'mdx',
'ts',
'tsx',
],
});

No manual imports are required.

Configure the plugin through gatsby-plugin-mdx.

gatsby-config.js
const rehypeMindElixir = require('rehype-mind-elixir');
module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-mdx',
options: {
mdxOptions: {
rehypePlugins: [
rehypeMindElixir,
],
},
},
},
],
};

No manual imports are required.

rehype-mind-elixir can also be used directly with Unified.

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeMindElixir from 'rehype-mind-elixir';
import rehypeStringify from 'rehype-stringify';
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeMindElixir)
.use(rehypeStringify)
.process(markdown);
console.log(String(file));

You can explicitly enable CDN mode:

const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeMindElixir, {
useCdn: true,
})
.use(rehypeStringify)
.process(markdown);

When using Unified directly, rehype-mind-elixir should run after remark-rehype because it operates on the HAST tree.

useCdn: trueuseCdn: false
DefaultYesNo
Automatic resource injectionYesNo
CDN resourcesYesNo
Manual importsNoYes
Bundled by applicationNoYes
Internet required at runtimeYesNo

See Configuration for the complete useCdn documentation and other plugin options.