assemble-contrib-anchors

Assemble plugin for creating anchor tags from headings in generated html using Cheerio.js.

npm install assemble-contrib-anchors
11 downloads in the last day
72 downloads in the last week
261 downloads in the last month

assemble-contrib-anchors NPM version

Assemble plugin for creating anchor tags from headings in generated html using Cheerio.js.

Quickstart

In the command line, run:

npm install assemble-contrib-anchors --save

Next, register the plugin with Assemble in your project's Gruntfile:

assemble: {
  options: {
    plugins: ['assemble-contrib-anchors', 'other/plugins/*']
  }
}

Configuration

You can also use the plugin with specific targets:

assemble: {
  foo: {
    options: {
      plugins: ['assemble-contrib-anchors'],
      layout: 'blog-post.hbs'
    },
    files: {'dist/': 'content/*.md'}
  },
  // The plugin won't run on this target
  bar: {
    files: {'dist/': 'templates/*.hbs'}
  }
}

To disable the plugin, either remove it from the options or specify anchors: {convert: false} in the options:

assemble: {
  foo: {
    options: {
      plugins: ['assemble-contrib-anchors'],
      anchors: {convert: false}
    },
    files: {'dist/': 'content/*.md'}
  }
}

Visit the plugins docs for more info or for help getting started.

Examples

Before

<h1 id="glyphicons">Glyphicons</h1>

After

<h1 class="docs-heading">
  <a href="#heading-id-name" name="heading-id-name" class="anchor">
    <span class="anchor-target" id="heading-id-name"></span>
    <span class="glyphicon glyphicon-link"></span>
  </a>
  Glyphicons
</h1>

Currently the plugin adds Bootstrap glyphicon classes. If you want to use different classes, find a bug, or have a feature request, plesae create an issue

Example

image

Visit the anchors example repo.

Assemble plugins

Here are some related projects you might be interested in from the Assemble core team.

Contributing

Find a bug? Have a feature request? Please create an Issue. Pull requests are also encouraged. If you find this project useful, please consider "starring" it to show your support! Thanks!

Authors

Jon Schlinkert

Brian Woodward

License

Copyright (c) 2014 Brian Woodward, contributors. Released under the MIT license


This file was generated by grunt-readme on Monday, January 27, 2014.

npm loves you