gpt4 book ai didi

jekyll - 使用 Jekyll 和 Kramdown 的目录

转载 作者:行者123 更新时间:2023-12-04 00:34:31 27 4
gpt4 key购买 nike

我正在尝试在我的 Jekyll 网站的页面(不是帖子)上使用 Kramdown 的自动“目录”生成器。

_includes/toc.html

<nav>
<h4>Table of Contents</h4>
{:toc}
</nav>

my_cool_stuff/my_cool_page.md
---
layout: page
---

{% include toc.html %}

# The title of my page
## The Subtitle of my page

HTML 是按字面生成的,我没有得到标题列表。
<nav>
<h4 class="toc_title">On This Page</h4>
{:toc}
</nav>

我设置错了什么?

最佳答案

{:toc} 是 kramdown tag for automatic Table of content generation .

在您的情况下,您还需要做两件事才能使其工作:

  • 允许 kramdown 解析内部 html 块:在 _config.yml添加 :
    kramdown:
    parse_block_html: true
  • _includes/toc.html ,您需要提供种子列表:
    <nav>
    <h4>Table of Contents</h4>
    * this unordered seed list will be replaced by toc as unordered list
    {:toc}
    </nav>
  • 关于jekyll - 使用 Jekyll 和 Kramdown 的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38417624/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com