Use the unified ecosystem in Eleventy with remark and rehype.
npm install eleventy-plugin-unified
Use the unified ecosystem in Eleventy.
You can render, transform and lint:
- markdown with the remark ecosystem.
- html with the rehype ecosystem.
- text with the retext ecosystem.
``bash`
npm install eleventy-plugin-unified remark-slug
`javascript
// .eleventy.config.cjs
const EleventyUnifiedPlugin = require("eleventy-plugin-unified");
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyUnifiedPlugin, ["remark-slug"]);
};
`
Then with a markdown file with:
`markdown`Hello, world
It will render like this:
`html`Hello, world
| Option | Description | Default |
| ------------------- | ------------------------------ | ---------------- |
| markdownTransforms | [remark plugins] | [] |[]
| htmlTransforms | [rehype plugins] | |[]
| textTransforms | [retext plugins] | |"."
| transformsDirectory | directory with your transforms | |
| textParser | retext parser | [retext-english] |
| reporter | [vfile reporter] | [vfile-reporter] |
[remark plugins]: https://unifiedjs.com/explore/keyword/remark
[rehype plugins]: https://unifiedjs.com/explore/keyword/rehype
[retext plugins]: https://unifiedjs.com/explore/keyword/retext
[retext-english]: https://www.npmjs.com/package/retext-english
[vfile-reporter]: https://github.com/vfile/vfile-reporter
[vfile reporter]: https://github.com/vfile/vfile#reporters
---
- Logging the available data
- Re-using eleventy filters
- Wrapping a table with a responsive container
- Style links that match the current page
- Configuring the reporter
- Turning off default reporter
- Configuring text parser language
`javascript`
// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, {
htmlTransforms: [["rehype-format", { indent: "\t" }]],
});
`javascript`
// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, [
"./plugins/responsive-tables.js",
]);
or
`javascript``
// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, {
transformsDirectory: "./plugins",
markdownTransforms: ["responsive-tables.js"],
});
---
- Titus for the Unified ecosystem
- florianeckerstorfer/eleventy-plugin-remark