@orchidjs/eleventy-plugin-ids

0.1.1 • Public • Published

eleventy-plugin-ids

@11ty plugin for adding ids to html headings and other elements

<h1>Foo Bar</h1>

will become

<h1 id="foo-bar">Foo Bar</h1>

Installation

npm install @orchidjs/eleventy-plugin-ids

Basic Usage

Add eleventy-plugin-ids to your .eleventy.js file

module.exports = function(eleventyConfig) {
	//...
	
	const anchors_plugin = require('@orchidjs/eleventy-plugin-ids');
	eleventyConfig.addPlugin(anchors_plugin);
	
	//...
}

Settings

module.exports = function(eleventyConfig) {
	//...
	
	const anchors_plugin = require('@orchidjs/eleventy-plugin-ids');
	eleventyConfig.addPlugin(anchors_plugin,{
		selectors: ['h1','h2','h3','h4','h5','h6'],
		prefix: 'custom-id-prefix-',
		formatter: function(element,existing_ids_array){
			return '--generate-a-custom-id-here-',
		}
	});
	
	//...
}

Package Sidebar

Install

npm i @orchidjs/eleventy-plugin-ids

Weekly Downloads

82

Version

0.1.1

License

Apache-2.0

Unpacked Size

14.3 kB

Total Files

5

Last publish

Collaborators

  • oyejorge