2.1.0 • Published 6 years ago
toc-anchor v2.1.0
TOC-Anchor

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>');