An open API service indexing awesome lists of open source software.

https://github.com/acyortjs/acyort-toc

Toc Helper for AcyOrt
https://github.com/acyortjs/acyort-toc

Last synced: about 1 month ago
JSON representation

Toc Helper for AcyOrt

Awesome Lists containing this project

README

          

# acyort-toc

Toc Helper for [AcyOrt](https://github.com/acyortjs/acyort)

## Install

```bash
$ npm i acyort-toc -S
```

## Usage

```yml
# config.yml
# ...
plugins:
- acyort-toc
# ...
```

```html


{{ _toc(page.raw) }}

```

Text slugify API

```js
const { slugify } = require('acyort-toc')

slugify('I ♥ Dogs') // i-love-dogs
slugify('这是@一#段$;¥中#文「【') // 这是-一-段-中-文
```

**you should slugify markdown heading id**

```js
const { slugify } = require('acyort-toc')

acyort.renderer.render('markdown', body, { getHeadingId: slugify })
```

### Advanced

```js
module.exports = (acyort) => {
const { helper } = acyort
const toc = helper.get('_toc')

toc('markdown raw string')
}
```

## Test

```bash
$ npm i acyort -g

$ npm t
```