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

github.com/yihui/hugo-xmag.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYihui Xie <xie@yihui.name>2017-07-12 06:13:57 +0300
committerYihui Xie <xie@yihui.name>2017-07-12 06:13:57 +0300
commit33ac2cfe541d9ca7b09d2dba1f39612ac94c6f0c (patch)
tree73522bbdd85dffbc28da92e7029d68c6b0295b8e
parentb1e24ab1bac48f12c01c6d37b12a17b00f1d23ca (diff)
support a placeholder when a post does not have any categories
-rw-r--r--exampleSite/content/about.md1
-rw-r--r--layouts/_default/list.html6
2 files changed, 5 insertions, 2 deletions
diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md
index 30de0f4..aaa898b 100644
--- a/exampleSite/content/about.md
+++ b/exampleSite/content/about.md
@@ -93,6 +93,7 @@ There are a few phrases that you can "translate" (I didn't use Hugo's multi-lang
edit = "Edit this page"
tags = "Tags: "
truncated = " &hellip;"
+ uncategorized = "Uncategorized"
```
You can define a data file under `data/` to store all authors information, e.g., you can use a TOML file `data/authors.toml` (or YAML/JSON):
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 8fb0d0b..459fa76 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -5,13 +5,15 @@
{{ $paginator := .Paginate (where .Data.Pages "Section" "!=" "") }}
{{ range $paginator.Pages }}
<section class="article-list">
+ <div class="categories">
{{ with .Params.categories }}
{{ range first 1 . }}
- <div class="categories">
<a href="{{ relURL (print "/categories/" . | urlize) }}">{{ . }}</a>
- </div>
{{ end }}
+ {{ else }}
+ <a>{{ default "Uncategorized" .Site.Params.text.uncategorized }}</a>
{{ end }}
+ </div>
<h1><a href="{{ .URL }}">{{ .Title }}</a></h1>
<div>
<span>{{ .Date.Format "2006/01/02" }}</span>