refactor: check toc in post frontmatter
This commit is contained in:
parent
8f9fa41512
commit
941d012611
32
README.md
32
README.md
|
@ -92,13 +92,37 @@ You can create a new blog post page by going to the root of your project and typ
|
|||
hugo new blog/:blog-post.md
|
||||
```
|
||||
|
||||
Where `:blog-post.md` is the name of the file of your new post.
|
||||
Where `:blog-post.md` is the name of the file of your new post.
|
||||
|
||||
Optional parameters for your post, added by the theme:
|
||||
This will execute the theme's `blog` archetype to create a new markdown file in `contents/blog/:blog-post.md` with the following frontmatter:
|
||||
|
||||
* `math:true` enables math renderig with KaTeX
|
||||
* `toc: true` adds a table of contents to your post
|
||||
```md
|
||||
# Default post frontmatter:
|
||||
|
||||
---
|
||||
# The title of your post. Default value is generated
|
||||
# From the markdown filename
|
||||
title: "{{ replace .TranslationBaseName "-" " " | title }}"
|
||||
# The date the post was created
|
||||
date: {{ .Date }}
|
||||
# The post filename
|
||||
slug: ""
|
||||
# Post description used for seo
|
||||
description: ""
|
||||
# Post keywords used for seo
|
||||
keywords: []
|
||||
# If true, the blog post will not be included in static build
|
||||
draft: true
|
||||
# Categorize your post with tags
|
||||
tags: []
|
||||
# Uses math typesetting
|
||||
math: false
|
||||
# Includes a table of contents
|
||||
toc: false
|
||||
---
|
||||
```
|
||||
|
||||
The frontmatter above is the default for a new post, but all values can be changed.
|
||||
|
||||
### Adding a new section menu
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@ description: ""
|
|||
keywords: []
|
||||
draft: true
|
||||
tags: []
|
||||
stylesheet: "post.css"
|
||||
math: false
|
||||
toc: false
|
||||
---
|
||||
|
|
|
@ -6,7 +6,8 @@ description: "This is an example post for hugo-theme-codex."
|
|||
keywords: ["gohugo", "hugo", "go", "blog"]
|
||||
draft: false
|
||||
tags: ["hugo"]
|
||||
stylesheet: "post.css"
|
||||
math: false
|
||||
toc: true
|
||||
---
|
||||
|
||||
## The standard Lorem Ipsum passage
|
||||
|
|
|
@ -6,7 +6,8 @@ description: "Sample article showcasing basic Markdown syntax and formatting for
|
|||
keywords: ["gohugo", "hugo", "go", "blog"]
|
||||
draft: false
|
||||
tags: ["markdown", "css", "html", "themes"]
|
||||
stylesheet: "post.css"
|
||||
math: false
|
||||
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.
|
||||
|
|
|
@ -6,8 +6,8 @@ description: "A brief guide to setup KaTeX"
|
|||
keywords: ["gohugo", "hugo", "go", "blog"]
|
||||
draft: false
|
||||
tags: ["math"]
|
||||
stylesheet: "post.css"
|
||||
math: true
|
||||
toc: false
|
||||
---
|
||||
|
||||
Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries.
|
||||
|
|
|
@ -6,7 +6,8 @@ description: "A brief description of Hugo Shortcodes"
|
|||
keywords: ["gohugo", "hugo", "go", "blog"]
|
||||
draft: false
|
||||
tags: ["shortcodes"]
|
||||
stylesheet: "post.css"
|
||||
math: false
|
||||
toc: false
|
||||
---
|
||||
|
||||
Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugo-s-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
{{ if or .Params.toc .Site.Params.toc }}
|
||||
{{ if .Params.toc }}
|
||||
<div class="toc-container">
|
||||
{{ if .Site.Params.showPageTitleInTOC }} <div class="toc-post-title">{{ .Title }}</div> {{ end }}
|
||||
{{ .TableOfContents }}
|
||||
|
@ -38,7 +38,7 @@
|
|||
{{ end }}
|
||||
|
||||
{{ define "scripts" }}
|
||||
{{ if or .Params.toc .Site.Params.toc }}
|
||||
{{ if .Params.toc }}
|
||||
<script src="/js/table-of-contents.js"></script>
|
||||
{{ end }}
|
||||
<script src="https://unpkg.com/prismjs@^1.2"></script>
|
||||
|
|
Loading…
Reference in New Issue