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

github.com/zwbetz-gh/papercss-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Betz <zwbetz@gmail.com>2019-02-27 06:04:07 +0300
committerZachary Betz <zwbetz@gmail.com>2019-02-27 06:04:07 +0300
commit9134c0596ed4f0b0a6f2118d58123697dc4d17a7 (patch)
tree8bc6e716b3fefc3865edebcd76ee044db180cba8
parent7ab6197b5742851d0a138abe5720d3ce768f7b54 (diff)
List font size, toc, anchor styles
-rw-r--r--README.md13
-rw-r--r--assets/css/custom.css27
-rw-r--r--exampleSite/content/post/papercss-shortcodes.md28
-rw-r--r--layouts/_default/terms.html4
-rw-r--r--layouts/partials/post-list.html4
-rw-r--r--layouts/partials/toc.html21
-rw-r--r--layouts/post/single.html6
7 files changed, 89 insertions, 14 deletions
diff --git a/README.md b/README.md
index 411fec7..3921ecc 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ A Hugo theme made with PaperCSS, the less formal CSS framework.
- [Configuration](#configuration)
- [Favicons](#favicons)
- [Shortcodes](#shortcodes)
+- [Disable toc for a blog post](#disable-toc-for-a-blog-post)
- [Getting help](#getting-help)
- [Credits](#credits)
@@ -61,6 +62,18 @@ Upload your image to [RealFaviconGenerator](https://realfavicongenerator.net/) t
See the [full list of supported shortcodes](https://papercss-hugo-theme.netlify.com/papercss-shortcodes/).
+## Disable toc for a blog post
+
+Blog posts that have two or more subheadings (`<h2>`s) automatically get a table of contents. To disable this set `toc` to `false`. For example:
+
+```
+---
+title: "My page with a few headings"
+toc: false
+---
+```
+
+
## Getting help
If you run into an issue that isn't answered by this documentation or the [`exampleSite`](https://github.com/zwbetz-gh/papercss-hugo-theme/tree/master/exampleSite), then visit the [Hugo forum](https://discourse.gohugo.io/). The folks there are helpful and friendly. **Before** asking your question, be sure to read the [requesting help guidelines](https://discourse.gohugo.io/t/requesting-help/9132). Feel free to tag me in your question, my forum username is [@zwbetz](https://discourse.gohugo.io/u/zwbetz/summary).
diff --git a/assets/css/custom.css b/assets/css/custom.css
index f67bb34..3ca5e3f 100644
--- a/assets/css/custom.css
+++ b/assets/css/custom.css
@@ -1,20 +1,47 @@
+/* base */
html {
font-size: calc(1em + 0.33vw);
}
body {
background-image: url('{{ "img/geometry2.png" | absURL }}');
}
+
+/* anchors */
a,
a:visited {
color: rgb(0, 0, 238);
+ background-image: none;
+ text-decoration: underline;
}
+
+/* navbar */
nav a,
nav a:visited {
color: #41403e;
+ text-decoration: none;
}
+
+/* blockquote */
blockquote {
font-style: italic;
}
+
+/* post list */
+.post-list {
+ font-size: 2em;
+}
+
+/* post single */
.post-title {
margin-bottom: 0.1em;
+}
+
+/* toc */
+.toc {
+ font-size: 0.85em;
+ padding: 1em;
+ margin-top: 1em;
+}
+.toc h2 {
+ font-size: 1.15em;
} \ No newline at end of file
diff --git a/exampleSite/content/post/papercss-shortcodes.md b/exampleSite/content/post/papercss-shortcodes.md
index 3c785f9..2cc5885 100644
--- a/exampleSite/content/post/papercss-shortcodes.md
+++ b/exampleSite/content/post/papercss-shortcodes.md
@@ -4,9 +4,13 @@ date: 2019-02-26T13:50:01-06:00
tags: [shortcodes]
---
-## Border
+## border
```
+{{</* border */>}}
+Regular
+{{</* /border */>}}
+
{{</* border "dashed" */>}}
Dashed
{{</* /border */>}}
@@ -24,6 +28,10 @@ Dotted Thick
{{</* /border */>}}
```
+{{< border >}}
+Regular
+{{< /border >}}
+
{{< border "dashed" >}}
Dashed
{{< /border >}}
@@ -40,7 +48,7 @@ Dashed Thick
Dotted Thick
{{< /border >}}
-## Color
+## color
```
{{</* color "primary" */>}}
@@ -92,7 +100,7 @@ Text danger
Text muted
{{< /color >}}
-## Background
+## background
```
{{</* background "primary" */>}}
@@ -136,7 +144,7 @@ Background warning
Background danger
{{< /background >}}
-## Alert
+## alert
```
{{</* alert "primary" */>}}
@@ -180,18 +188,18 @@ Alert-warning
Alert-danger
{{< /alert >}}
-## Badge
+## badge
```
<h3>Example badge {{</* badge */>}}123{{</* /badge */>}}</h3>
-<h3>Example badge {{</* badge "secondary" >}}123{{</* /badge */>}}</h3>
+<h3>Example badge {{</* badge "secondary" */>}}123{{</* /badge */>}}</h3>
-<h3>Example badge {{</* badge "success" >}}123{{</* /badge */>}}</h3>
+<h3>Example badge {{</* badge "success" */>}}123{{</* /badge */>}}</h3>
-<h3>Example badge {{</* badge "warning" >}}123{{</* /badge */>}}</h3>
+<h3>Example badge {{</* badge "warning" */>}}123{{</* /badge */>}}</h3>
-<h3>Example badge {{</* badge "danger" >}}123{{</* /badge */>}}</h3>
+<h3>Example badge {{</* badge "danger" */>}}123{{</* /badge */>}}</h3>
```
<h3>Example badge {{< badge >}}123{{< /badge >}}</h3>
@@ -204,7 +212,7 @@ Alert-danger
<h3>Example badge {{< badge "danger" >}}123{{< /badge >}}</h3>
-## Card
+## card
```
TODO
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
index 0f0bcca..e92be4a 100644
--- a/layouts/_default/terms.html
+++ b/layouts/_default/terms.html
@@ -6,11 +6,11 @@
{{ $name := .Name }}
{{ $count := .Count }}
{{ with $.Site.GetPage (printf "/%s/%s" $type $name) }}
- <h3>
+ <h2 class="post-list">
<a href="{{ .Permalink }}">
{{ printf "(%d) %s" $count $name }}
</a>
- </h3>
+ </h2>
{{ end }}
{{ end }}
diff --git a/layouts/partials/post-list.html b/layouts/partials/post-list.html
index 00d60a2..2ee64b7 100644
--- a/layouts/partials/post-list.html
+++ b/layouts/partials/post-list.html
@@ -1,8 +1,8 @@
<h1>{{ .Title }}</h1>
{{ range where .Pages.ByPublishDate.Reverse "Section" "post" }}
-<h3>
+<h2 class="post-list">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
-</h3>
+</h2>
{{ end }} \ No newline at end of file
diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html
new file mode 100644
index 0000000..8879bd6
--- /dev/null
+++ b/layouts/partials/toc.html
@@ -0,0 +1,21 @@
+{{ $headings := findRE "<h2.*?>(.|\n])+?</h2>" .Content }}
+{{ if ge (len $headings) 2 }}
+<div class="child-borders">
+ <div class="toc border" aria-labelledby="toc-heading">
+ <h2 id="toc-heading">Table of contents</h2>
+ <ol>
+ {{ range $headings }}
+ <li>
+ {{ $id := findRE "id=\".*\"" . }}
+ {{ $id = index $id 0 }}
+ {{ $id = strings.TrimPrefix "id=\"" $id }}
+ {{ $id = strings.TrimSuffix "\"" $id }}
+ <a href="#{{ $id }}">
+ {{ . | htmlUnescape | plainify }}
+ </a>
+ </li>
+ {{ end }}
+ </ol>
+ </div>
+</div>
+{{ end }} \ No newline at end of file
diff --git a/layouts/post/single.html b/layouts/post/single.html
index c5476fb..104653b 100644
--- a/layouts/post/single.html
+++ b/layouts/post/single.html
@@ -1,6 +1,7 @@
{{ define "main" }}
<h1 class="post-title">{{ .Title }}</h1>
+
{{ $dateFormat := $.Site.Params.dateFormat | default "Jan 2, 2006" }}
<strong>Publish date: </strong>{{ .PublishDate.Format $dateFormat }}
<br>
@@ -10,6 +11,11 @@
<a href="{{ "tags/" | absURL }}{{ . | urlize }}">{{ . }}</a>
{{ end }}
{{ end }}
+
+{{ if ne .Params.toc false }}
+ {{ partial "toc.html" . }}
+{{ end }}
+
{{ .Content }}
{{ end }} \ No newline at end of file