Skip to content

Commit

Permalink
Add the toc parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Nov 15, 2020
1 parent 81ddac2 commit 8358962
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ As the example site shown, the configuration are separated into multiple files,
| `mainSections` | Array | `["posts"]` | Main sections
| `titleSeparator` | String | `-` | Title separator
| `comment` | Boolean | `true` | Whether to enable comments
| `toc` | Boolean | `true` | Whether to enable TOC
| `utterances` | Object | - | Utterances comments
| `dateFormat` | String | `Jan 2, 2006` | Date format. Checkout the [Hugo Date and Time Templating Reference](https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference) for details.
| `poweredBy` | Boolean | `true` | Whether to show powered by.
Expand Down Expand Up @@ -157,6 +158,7 @@ As the example site shown, the configuration are separated into multiple files,
|---|:-:|:-:|---
| **Page**
| `comment` | Boolean | `true` | Whether to enable comments. It won't work if `comment` has been disabled globally.
| `toc` | Boolean | `true` | Whether to enable TOC. It won't work if `toc` has been disabled globally.
| `math` | Boolean | `false` | Whether to enable math.

## Comments
Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $ hugo server
| `mainSections` | Array | `["posts"]` | 主要的 sections
| `titleSeparator` | String | `-` | 标题分隔符
| `comment` | Boolean | `true` | 是否开启评论
| `toc` | Boolean | `true` | 是否开启目录
| `utterances` | Object | - | Utterances
| `dateFormat` | String | `Jan 2, 2006` | 日期格式。 查阅 [Hugo Date and Time Templating Reference](https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference) 以获取详细信息。
| `poweredBy` | Boolean | `true` | 是否显示技术支持。
Expand Down Expand Up @@ -157,6 +158,7 @@ $ hugo server
|---|:-:|:-:|---
| **Page**
| `comment` | Boolean | `true` | 是否开启评论,如果评论已被全局关闭,该参数无效
| `toc` | Boolean | `true` | 是否开启目录,如果目录已被全局关闭,该参数无效
| `math` | Boolean | `false` | 是否开启 `math`

## 评论
Expand Down
2 changes: 2 additions & 0 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $ hugo server
| `mainSections` | Array | `["posts"]` | 主要的 sections
| `titleSeparator` | String | `-` | 標題分隔符
| `comment` | Boolean | `true` | 是否開啟評論
| `toc` | Boolean | `true` | 是否開啟目錄
| `utterances` | Object | - | Utterances
| `dateFormat` | String | `Jan 2, 2006` | 日期格式。 查閱 [Hugo Date and Time Templating Reference](https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference) 以獲取詳細資訊。
| `poweredBy` | Boolean | `true` | 是否顯示技術支援。
Expand Down Expand Up @@ -157,6 +158,7 @@ $ hugo server
|---|:-:|:-:|---
| **Page**
| `comment` | Boolean | `true` | 是否開啟評論,如果評論已被全域性關閉,該引數無效
| `toc` | Boolean | `true` | 是否開啟目錄,如果目錄已被全域性關閉,該引數無效
| `math` | Boolean | `false` | 是否開啟 `math`

## 評論
Expand Down
1 change: 1 addition & 0 deletions archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description = ""
date = {{ .Date }}
draft = true
comment = true
toc = true
categories = [
""
]
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ palette = "blue" # Default palette. Optional.
googleAdsense = ""

# math = true # Enable math globally.
# toc = false # Disable TOC globally.

# poweredBy = false # Whether to show powered by.

Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/posts/markdown-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ aliases = ["migrate-from-jekyl"]
images = [
"images/markdown.png"
]
# toc = false
+++

This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/post/toc.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- $enable := and (default true .Params.toc) (default true .Site.Params.toc) -}}
{{- $toc := .TableOfContents -}}
{{- if and $toc (ne $toc "<nav id=\"TableOfContents\"></nav>") -}}
{{- $valid := and $toc (ne $toc "<nav id=\"TableOfContents\"></nav>") -}}
{{- if and $enable $valid -}}
<aside class="post-toc border col-md-4 surface">
{{- $toc -}}
</aside>
Expand Down

0 comments on commit 8358962

Please sign in to comment.