@code-blocks/eleventy-plugin

An eleventy plugin to parse code blocks

Usage no npm install needed!

<script type="module">
  import codeBlocksEleventyPlugin from 'https://cdn.skypack.dev/@code-blocks/eleventy-plugin';
</script>

README

@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:

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.