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

astro-toc

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-toc

Table of Contents (ToC) generator for Astro. Use custom components for interactivity.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source
astro-toc logo

astro-toc

license npm

Table of Contents (ToC) generator for Astro

Open in StackBlitz

Table of Contents

Install

npm install astro-toc

Usage

Classic

This render mode can render your toc as <ul>, <ol> or <menu>; set the style property to select your flavour.

PropertyTypeDescription
toc{ depth: number; title: string; url?: string; [string]: any }[]depth and title are required.
style optionalstringbullet | number | menu
maxDepth optionalnumber | stringHow many levels should be rendered
---
import { TOC } from "astro-toc";

const toc = [
  {depth: 1, title: "Tours", url: /* optional*/},
  {depth: 2, title: "Walking Tours"},
  {depth: 3, title: "City Walking Tours"},
  {depth: 3, title: "River Walking Tours"},
  {depth: 2, title: "Boat Tours"},
  {depth: 1, title: "Restaurants"},
  {depth: 2, title: "Fine Dining"},
  {depth: 2, title: "Gastropub"},
  {depth: 2, title: "Fast Food"},
  {depth: 1, title: "Hotels"},
];
---

<TOC toc={toc} />

Component

When using a custom component it uses the <menu> element.

Unlike the classic render method title isn't required and the payload will be passed to the component.

PropertyTypeDescription
toc{ depth: number; [string]: any }[]depth is required.
use(props) => anyAstro component
maxDepth optionalnumber | stringHow many levels should be rendered
---
import { TOC } from "astro-toc";
import MyComponent from "path/to/MyComponent.astro";

const toc = [
  {depth: 1, title: "Tours"},
  {depth: 2, title: "Walking Tours"},
  {depth: 3, title: "City Walking Tours"},
  {depth: 3, title: "River Walking Tours"},
  {depth: 2, title: "Boat Tours"},
  {depth: 1, title: "Restaurants"},
  {depth: 2, title: "Fine Dining"},
  {depth: 2, title: "Gastropub"},
  {depth: 2, title: "Fast Food"},
  {depth: 1, title: "Hotels"},
];
---

<TOC toc={toc} use={MyComponent} />

License

ISC

Keywords

FAQs

Package last updated on 23 Oct 2022

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