3.7插件TOC目录

插件TOC目录

安装

npm install hexo-toc –save

配置

_config.yml中添加

1
2
toc:  
maxDepth: 3

maxDepth 表示目录深度为3,即最多生成三级目录。

官方文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
toc:
maxdepth: 3
class: toc
slugify: transliteration
decodeEntities: false
anchor:
position: after
symbol: '#'
style: header-anchor
maxdepth: Use headings whose depth is at most maxdepth.
class: The CSS Class for the toc. (Default is false)
slugify: Choose which slugify function you want to use. Currently support uslug (Default) and transliteration.
decodeEntities: Select whether to enable decode entities. ( Default is false and please see #15).
anchor: Whether should have an anchor for each headings. (Default is false)
position: Where should the anchor be, before the title, or after the title. (Default is after);
symbol: Which symbol you want the anchor be. (Default is #);
style: The CSS class for the anchor, (Default is header-anchor);

maxdepth:使用深度最大为maxdepth的标题。

class:toc的CSS类(默认值为false)

slugify:选择要使用的slugify函数。目前支持uslug(默认)和音译。

解码实体:选择是否启用解码实体。(默认值为false)。

锚定:每个标题是否应有锚定(默认为false)位置:锚定应该在哪里,在标题之前,还是在标题之后(默认为之后);

符号:您希望锚点是哪个符号(默认值为#);

样式:锚定的CSS类(默认为header锚定);

next中toc外加属性

wrap: false

#如果为true,则如果标题宽度大于侧边栏宽度,则所有单词将放在下一行。

number: false

#自动将列表编号添加到目录。一般在文章中就编号了

没搞明白,可能是我已经安装了next主题,看不出效果

next主题

1.next默认是有目录结构的

1.1默认展开,字体大小

themes/next/source/css/_custom/custom.styl

1
2
3
4
5
6
//文章目录默认展开 
.post-toc .nav .nav-child { display: block; }
//调整字体大小
.post-toc ol {
font-size : 13px;
}

1.2自动换行

1
2
3
toc:
enable: true
wrap: true

2.next自带属性

1
2
3
4
5
6
7
8
9
# Table Of Contents in the Sidebar 侧边栏中的目录

toc:
enable: true
# Automatically add list number to toc.自动将列表编号添加到目录。一般在文章中就编号了
number: false
# If true, all words will placed on next lines if header width longer then sidebar width.
#如果为true,则如果标题宽度大于侧边栏宽度,则所有单词将放在下一行。
wrap: false