Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@danielhaim/autotoc

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@danielhaim/autotoc

NPM package for generating and managing table of contents with scroll highlighting for web content

  • 1.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

AutoTOC API

npm version Downloads GitHub

Overview

AutoTOC is an NPM package for automatically generating and managing table of contents with scroll highlighting for web content

CodePen Demo

API Documentation

Getting Started

To initiate, install AutoTOC using NPM:

npm i @danielhaim/autotoc

Module Example

import AutoToc from "@danielhaim/autotoc";

document.addEventListener("DOMContentLoaded", function () {
    const tocOptions = {
        contentSelector: "article",
        navigationContainer: "nav",
        tocTitle: "Table of Contents",
        tocIcon: '<i class="your-icon-class"></i>',
        highlightOffset: 100,
        headingDepthLimit: 4
    };

    // Appends to Top
    const externalLinksTop = [
        { id: "external-link1", text: "Custom Top Link 1" },
        { id: "external-link2", text: "Custom Top Link 2" }
    ];

    // Appends to Bottom
    const externalLinksBottom = [
        { id: "external-link3", text: "Custom Bottom Link 3" },
        { id: "external-link4", text: "Custom Bottom Link 4" }
    ];

    try {
        const tocGenerator = new AutoToc.Generate(
            ...Object.values(tocOptions)
        );

        tocGenerator.addExternalLinksToToc(externalLinksTop, "top", "level-0");
        tocGenerator.addExternalLinksToToc(externalLinksBottom, "bottom", "level-0");
        tocGenerator.initialize();
    } catch (error) {
        console.error("An error occurred:", error.message);
    }
});

Keywords

FAQs

Package last updated on 29 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc