【问题标题】:Is there a way to write a Jekyll liquid template that automatically prints headers and subheaders of a markdown file?有没有办法编写一个自动打印 Markdown 文件的标题和子标题的 Jekyll 液体模板?
【发布时间】:2015-05-12 17:17:35
【问题描述】:

我有一个带有 markdown 的 Jekyll 网站,如下所示:

#Header 1

Some text

##Subheader 1

Some subheader text

#Header 2

etc

是否可以编写一个液体模板,以便我的侧边栏可以显示一种包含所有标题和子标题的目录?

(假代码):

{{%foreach header | print header %}}
 {{%foreach subheader | subheader here %}} 
{{%end%}}

【问题讨论】:

    标签: jekyll liquid


    【解决方案1】:

    是的,这是目录或 ToC。

    使用默认的 Jekyll Markdown 解析器 Kramdown,您可以立即使用它。

    * Will be replaced with the ToC, excluding the "Contents" header
    {:toc}
    
    #Header 1
    
    Some text
    
    ##Subheader 1
    
    Some subheader text
    
    #Header 2
    

    See Kramdown documentation for options

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2016-05-28
      • 1970-01-01
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多