Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/yihui/hugo-xmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYihui Xie <xie@yihui.name>2017-06-23 06:33:39 +0300
committerYihui Xie <xie@yihui.name>2022-06-15 06:53:33 +0300
commit1a346c67b858f5daa328f583ce464aa24327b91e (patch)
treeca5318f1416b0f768226c6a277eda0fdd7edf176
parentae0bdbeb103133c15936fd15d77f9bba6119e59d (diff)
support table of contents for Markdown posts
-rw-r--r--exampleSite/content/about.md1
-rw-r--r--layouts/_default/single.html4
-rw-r--r--static/css/style.css4
3 files changed, 9 insertions, 0 deletions
diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md
index 804e82b..a16050a 100644
--- a/exampleSite/content/about.md
+++ b/exampleSite/content/about.md
@@ -1,6 +1,7 @@
---
title: About Hugo XMin
author: Yihui Xie
+toc: true
---
**XMin** is the first Hugo theme I have designed. The original reason that I wrote it was I needed a minimal example of Hugo themes when I was writing the [**blogdown**](https://github.com/rstudio/blogdown) book. Basically I wanted a simple theme that supports a navigation menu, a home page, other single pages, lists of pages, blog posts, categories, tags, and RSS. That is all. Nothing fancy. In terms of CSS and JavaScript, I really want to keep them minimal. In fact, this theme does not contain any JavaScript code at all, although on this example website I did introduce some JavaScript code (still relatively simple anyway). The theme does not contain any images, either, and is pretty much a plain-text theme.
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index de3f121..31d2d2a 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -5,6 +5,10 @@
{{ if (gt .Params.date 0) }}<h2 class="date">{{ .Date.Format "2006/01/02" }}</h2>{{ end }}
</div>
+{{ if .Params.toc }}
+{{ .TableOfContents }}
+{{ end }}
+
<main>
{{ .Content }}
</main>
diff --git a/static/css/style.css b/static/css/style.css
index 0b51cd6..e0d6f9c 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -21,6 +21,10 @@ hr {
border-style: dashed;
color: #ddd;
}
+#TableOfContents, #TOC {
+ border: 1px solid #eee;
+ border-radius: 5px;
+}
/* code */
pre {