2.0.0 • Published 1 year ago

eleventy-plugin-unified v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

OptionDescriptionDefault
markdownTransformsremark plugins[]
htmlTransformsrehype plugins[]
textTransformsretext plugins[]
transformsDirectorydirectory with your transforms"."
textParserretext parserretext-english
reportervfile reportervfile-reporter

Documentation

Configure options for transforms

Adding your own transforms

Using page context and eleventy data

Transforming markdown with remark

Transforming html with rehype

Reporting and linting with retext

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