Skip to content

Use the unified ecosystem in Eleventy with remark and rehype.

Notifications You must be signed in to change notification settings

NickColley/eleventy-plugin-unified

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eleventy Plugin Unified

past latest npm version

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.

Install

npm install eleventy-plugin-unified remark-slug
// .eleventy.config.cjs
const EleventyUnifiedPlugin = require("eleventy-plugin-unified");

module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(EleventyUnifiedPlugin, ["remark-slug"]);
};

Then with a markdown file with:

# Hello, world

It will render like this:

<h1 id="hello-world">Hello, world</h1>

Plugin options

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

Documentation

Configure options for transforms

// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, {
  htmlTransforms: [["rehype-format", { indent: "\t" }]],
});

Adding your own transforms

// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, [
  "./plugins/responsive-tables.js",
]);

or

// .eleventy.js
eleventyConfig.addPlugin(EleventyUnifiedPlugin, {
  transformsDirectory: "./plugins",
  markdownTransforms: ["responsive-tables.js"],
});

With thanks to

About

Use the unified ecosystem in Eleventy with remark and rehype.

Resources

Stars

Watchers

Forks