@@ -215,6 +215,21 @@ Options for [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-
The key and value pair will be added to `<a>` tags that point to an external link. The default option will open external links in a new window.
### markdown.toc
- Type: `Object`
This attribute will control the behaviour of `[[TOC]]`. It contains the following options:
- includeLevel: [number, number], level of headers to be included, defaults to `[2, 3]`.
- containerClass: string, the class name for the container, defaults to `table-of-contents`.
- markerPattern: RegExp, the regular expression for the marker to be replaced with TOC, defaults to `/^\[\[toc\]\]/im`.
- listType: string or Array, labels for all levels of the list, defaults to `"ul"`.
- containerHeaderHtml: string, an HTML string for container header, defaults to `""`.
- containerFooterHtml: string, an HTML string for container footer, defaults to `""`.
We also provide a [global component TOC](../guide/using-vue.md#toc) which allows for more free control by passing props directly to `<TOC>`.
### markdown.plugins
You can install any markdown-it plugins through `markdown.plugins` option. It is similar with [using VuePress plugins](../plugin/using-a-plugin.html#using-a-plugin). You can either use Babel style or object style. The `markdown-it-` prefix is optional and can omit in the list.
@@ -101,7 +101,7 @@ For more details, check out the [Front Matter](./frontmatter.md) page.
A list of all emojis available can be found [here](https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.json).
## Table of Contents <Badge text="default theme"/>
## Table of Contents
**Input**
...
...
@@ -109,13 +109,17 @@ A list of all emojis available can be found [here](https://github.com/markdown-i
[[toc]]
```
or
```md
<TOC/>
```
**Output**
[[toc]]
Rendering of TOC can be configured using the [`themeConfig.toc`](../theme/default-theme-config.md#table-of-contents) option.
> You can also use the official plugin [vuepress-plugin-toc](https://vuepress.github.io/plugins/toc/) for an advanced `<TOC/>` component.
Rendering of TOC can be configured using the [`markdown.toc`](../config/README.md#markdown-toc) option, or as props of [TOC component](./using-vue.md#toc), like `<TOC list-type="ol" :include-level="[2, Infinity]"/>`.
@@ -224,6 +224,28 @@ Specify a specific slot for a specific page (.md) for rendering. This will be ve
-[Markdown Slot](./markdown-slot.md)
-[Writing a theme > Content Outlet](../theme/writing-a-theme.md#content-outlet)
### TOC <Badge text="1.0.0-alpha.41+"/>
-**Props**:
-`listType` - string or Array, defaults to `"ul"`
-`includeLevel` - [number, number], defaults to `[2, 3]`
-**Slots**: `header`, `footer`
-**Usage**:
You can add a custom table of contents by specify some props to this component. `includeLevel` decides which level of headers should be included. `listType` decides the tags of lists. If specified as an array, the component will take the first element as the first-level list type and so on. If there are not enough values provided, the last value will be used for all the remaining list types.
``` md
<TOC:list-type="['ol', 'ul']">
<pslot="header"><strong>Custom Table of Contents</strong></p>
</TOC>
```
<TOC:list-type="['ol', 'ul']">
<pslot="header"><strong>Custom Table of Contents</strong></p>
Options for [markdown-it-table-of-contents](https://github.com/Oktavilla/markdown-it-table-of-contents#options). The default options are `{ includeLevel: [2, 3] }`.
::: tip
1. You should always use [`markdown.slugify`](../config/#markdown-slugify) instead of `themeConfig.toc.slugify` if you want to customize header ids.
2. Setting `themeConfig.toc` to `false` will disable the `[[toc]]` syntax (in case you want to switch to other plugins, such as [vuepress-plugin-toc](https://vuepress.github.io/plugins/toc/)).