@code-blocks/eleventy-plugin
An eleventy plugin to parse code blocks
Usage
Install the plugin:
npm install @code-blocks/eleventy-plugin --save
Install the renderers you need, for example:
npm install @code-blocks/music --save
In the .eleventy.js
configuration file:
// the plugin
const codeblocks = require('@code-blocks/eleventy-plugin')
// some renderers
const math = require('@code-blocks/math')
const music = require('@code-blocks/music')
module.exports = function(eleventyConfig) {
// pass the renderers to the plugin
eleventyConfig.addPlugin(codeblocks([
math,
music,
]))
}
Available renderers:
- @code-blocks/charts
- @code-blocks/graphviz
- @code-blocks/math
- @code-blocks/music
- @code-blocks/tables
- @code-blocks/prism
There is already an official syntax highlighting plugin for eleventy. If you are just going to highlight code blocks, use that instead. However, if you are using other @code-blocks
renderers, it will break the official plugin. That is why there is a @code-blocks/prism
renderer.