@sardine/eleventy-plugin-code-highlighter
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@sardine/eleventy-plugin-code-highlighter

An 11ty plugin to style your <code>.

Features

This plugin uses Prism to style <code> blocks at build time and inlines Prism CSS theme in the page <head>.

Because styling is done at build time, you don't need to asynchronously load CSS and Javascript on the browser.

Requirements

Installation

npm install --save-dev @sardine/eleventy-plugin-code-highlighter

How to use it

// .eleventy.js
const codeHighlighter = require('@sardine/eleventy-plugin-code-highlighter');
module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(codeHighlighter);
};

Options

By default the Tomorrow theme is used. You can use any Prism theme by passing the theme URL as an option.

// .eleventy.js
const codeHighlighter = require('@sardine/eleventy-plugin-code-highlighter');

const PRISM_THEME = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-twilight.min.css';

module.exports = function (eleventyConfig) {
  eleventyConfig.addPlugin(codeHighlighter, { urlTheme: PRISM_THEME });
};

License

MIT

Dependents (0)

Package Sidebar

Install

npm i @sardine/eleventy-plugin-code-highlighter

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

16.8 kB

Total Files

8

Last publish

Collaborators

  • petinga
  • marabyte