toc-anchor

2.1.0 • Public • Published

TOC-Anchor npm Build Status

Automatically adds anchors to elements.

Installation

npm install toc-anchor

Usage

In your project import the library:

import TocAnchor from ‘toc-anchor’;

Import default styles.

TocAnchor(selector, [anchorContent])

Initializes anchor library. Both the first and second argument can either be a selector, DOM node, or a collection of DOM Nodes.

Parameters

selector {string|Element|NodeList} - Selector to which anchors will be added

[anchorContent] {string|Element|NodeList} - Content to be included as anchor, if no provided a clip icon will be added by default

Returns

Array - Array containing the elements to which anchors where added

Example

const els = TocAnchor('.my-class h1', '<span class="anchor-icon"></span>');

Readme

Keywords

Package Sidebar

Install

npm i toc-anchor

Weekly Downloads

14

Version

2.1.0

License

MIT

Unpacked Size

10.5 kB

Total Files

7

Last publish

Collaborators

  • alaguna
  • aleperez92
  • dawnerd
  • jga
  • orthagonal1