New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tradegecko/static-site-toc-generator

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tradegecko/static-site-toc-generator

Adds a ToC array to broccoli-static-site-json ouput

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

static-site-toc-generator

This is addon is intended to be used with broccoli-static-site-json

Input/Output

The JSON should have the following shape

{
  data: {
    attributes: {
      html: ''
    }
  }
}

The output JSON will be

{
  data: {
    attributes: {
      html: ''
      toc: [
        {
         level: //what h tag was it [1,2,3,4]?
         id: //the id of the htag
         label: //the innerText of the htag
    }
      ]
    }
  }
}

The ToC array is flat and the order of the tags in the order that they were found in the HTML.

Installation

npm install @tradegecko/static-site-toc-generator

Usage

const jsonTree = new StaticSiteJson(folder, staticSiteConfig);
const jsonTreeWithToc = new MarkDownTableOfContents(jsonTree, {depth: siteGeneratorOptions.markdownTocDepth});

Now you should use jsonTreeWithToc for the rest of your pipeline since the original output of StaticSiteJson does not contain the toc attribute.

Below is an example ember component consuming the array.

  <nav class="navigation">
    <ul class="list">
      {{#each @toc as |toc|}}
      <li class="list-item">
        <a class="link" href="#{{toc.id}}">{{toc.label}}</a>
      </li>
      {{/each}}
    </ul>
  </nav>

FAQs

Package last updated on 16 Jun 2019

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