如果我在Jekyll中有一个带标题的页面/帖子,是否可以自动生成目录/大纲以进行导航?类似于维基百科文章的最重要的东西.
man*_*ork 38
这是标记解析器的任务.
在Markdown的情况下,其中一个语法扩展定义了自动生成目录:
* This will become a table of contents (this text will be scraped).
{:toc}
Run Code Online (Sandbox Code Playgroud)
所以我所有的Jekyll帖子都有一个目录部分.它可以使用kramdown完成.
在您希望显示TOC的帖子中使用此代码
* Do not remove this line (it will not be displayed)
{:toc}
Run Code Online (Sandbox Code Playgroud)
并使用这个CSS来设置它像维基百科TOC
// Adding 'Contents' headline to the TOC
#markdown-toc::before {
content: "Contents";
font-weight: bold;
}
// Using numbers instead of bullets for listing
#markdown-toc ul {
list-style: decimal;
}
#markdown-toc {
border: 1px solid #aaa;
padding: 1.5em;
list-style: decimal;
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
使用适合您博客的适当颜色.
这就对了!
如果在任何情况下上述方法都不起作用,TOC也可以在jekyll-of-contents的帮助下完成.这个使用Jquery和一个js文件.
以下是我如何做到的详细指南:Jekyll TOC
归档时间: |
|
查看次数: |
7224 次 |
最近记录: |