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

github.com/parsiya/Hugo-Octopress.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsiya@gmail.com <parsiya@gmail.com>2016-08-25 08:23:49 +0300
committerparsiya@gmail.com <parsiya@gmail.com>2016-08-25 08:23:49 +0300
commitdcd9aadd0a9359740d508f3c41d659f9dd5ac071 (patch)
tree8eeff50668d53901eab55dccb0758b4c2eadcf01
parent34ea63bdbc57205443a81bc0b86036d46dad325b (diff)
Add taxonomy page functionality. Fixes #21
-rw-r--r--README.md18
-rw-r--r--layouts/_default/terms.html40
-rw-r--r--layouts/partials/sidebar.html48
-rw-r--r--sample-config.toml14
4 files changed, 92 insertions, 28 deletions
diff --git a/README.md b/README.md
index 611adfb..929f230 100644
--- a/README.md
+++ b/README.md
@@ -20,9 +20,10 @@ Hugo-Octopress is a port of the classic [Octopress][octopress-link] theme to [Hu
- [License page](#licensepage)
- [Table of contents](#tableofcontents)
- [Not Found or 404.html](#notfound)
+- [Taxonomy pages](#taxonomy)
- [Issues/TODO](#issues)
- [Attribution](#attribution)
-- [Ported by](#porterby)
+- [Ported by](#portedby)
- [Theme license](#themelicense)
![screenshot](/images/screenshot.png)
@@ -364,6 +365,19 @@ There are two optional parameters in the config file and both support markdown:
If they are not set in the config file, a default page is generated.
+## <a name="taxonomy"></a>Taxonomy pages
+The theme can create pages that list all taxonomies (categories and tags) and their count. The taxonomy pages are at `baseURL/tags/` and `baseURL/categories`. This can be accomplished by adding `generateTaxonomyList = true` to the config file. By default the theme sorts the items by count. It can be changed to alphabetical by including `sortTaxonomyAlphabetical = true`.
+
+The switches are as follows:
+
+ [Params]
+ generateTaxonomyList = true
+
+ # This is not needed unless alphabetical sort is needed
+ # sortTaxonomyAlphabetical = true
+
+To revert back to ByCount sort, remove `sortTaxonomyAlphabetical` or set it to false.
+
## <a name="issues"></a>Issues/TODO
If you see any issues/bugs or you are looking for some features please use the Github issue tracker. Please keep in my mind that my day job is not development and I may be slow in fixing things (or I may ask you to help me with it).
@@ -380,7 +394,7 @@ If you know how to clean it up, please let me know or better yet help me do it :
## <a name="Ported by"></a>Ported by
Ported by Parsia Hakimian:
-* website: [parsiya.net](http://parsiya.net)
+* website: [parsiya.net](https://parsiya.net)
* twitter: [@CryptoGangsta](https://twitter.com/cryptogangsta)
## <a name="themelicense"></a>Theme license
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
new file mode 100644
index 0000000..a3b6927
--- /dev/null
+++ b/layouts/_default/terms.html
@@ -0,0 +1,40 @@
+<!-- Template for /tags/ and /categories/ -->
+
+{{ $page := . }}
+{{ $data := .Data }}
+{{ $.Scratch.Set "terms" $data.Terms.ByCount }} <!-- default is ByCount -->
+
+{{ with .Site.Params.generateTaxonomyList }}
+
+ {{ partial "header.html" $page }}
+ <div id="main">
+ <div id="content">
+ <div>
+ <article role="article">
+ <header>
+ <h1 class="entry-title">
+ {{ $.Title }}:
+ </h1>
+ </header>
+ <ul>
+ {{ with $.Site.Params.sortTaxonomyAlphabetical }}
+ {{ if eq . true }}
+ {{ $.Scratch.Set "terms" $data.Terms.Alphabetical }}
+ {{ end }}
+ {{ end }}
+ <!-- Non-relative paths also work - fallback in case the relative path stops working -->
+ {{ range $key, $value := ($.Scratch.Get "terms") }}
+ <!-- <li><a href="{{ $.Site.BaseURL }}{{ $data.Plural }}/{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li> -->
+ <li><a href="{{ $value.Name | urlize }}">{{ humanize $value.Name }}</a> {{ $value.Count }}</li>
+ {{ end }}
+ </ul>
+ </article>
+ </div>
+
+ {{ partial "sidebar.html" $page }}
+ </div>
+ </div>
+
+ {{ partial "footer.html" $page }}
+
+{{ end }}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index a22412b..1cb3fec 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -42,32 +42,36 @@
first we check if it is enabled in config file and then start adding the items
if Site.Params.sidebarNewWindow exists and is set to true then open these links in a new window -->
- {{ if eq .Site.Params.sidebarMenuEnabled true }}
- <section class="odd">
- {{ if isset .Site.Params "sidebarMenuHeader" }}
- <h1>{{ .Site.Params.sidebarMenuHeader }}</h1>
- {{ end }}
- {{ range .Site.Menus.sidebar }}
- <li>
- <a href="{{ .URL | absURL }}" title="{{ .Name }}" {{ if eq $.Site.Params.sidebarNewWindow true }} target="_blank" {{ end }}>{{ .Name }}</a>
- </li>
- {{ end }}
- </section>
+ {{ with .Site.Params.sidebarMenuEnabled }}
+ {{ if eq . true }}
+ <section class="odd">
+ {{ if isset $.Site.Params "sidebarMenuHeader" }}
+ <h1>{{ $.Site.Params.sidebarMenuHeader }}</h1>
+ {{ end }}
+ {{ range $.Site.Menus.sidebar }}
+ <li>
+ <a href="{{ .URL | absURL }}" title="{{ .Name }}" {{ if eq $.Site.Params.sidebarNewWindow true }} target="_blank" {{ end }}>{{ .Name }}</a>
+ </li>
+ {{ end }}
+ </section>
+ {{ end }}
{{ end }}
<!-- add recent posts - limit is .Site.Params.sidebarRecentLimit - example copied from https://gohugo.io/templates/go-templates/ -->
<!-- only display this section if sideBarRecentLimit is not zero -->
- {{ if not (eq .Site.Params.sidebarRecentLimit 0) }}
- <section class="even">
- <h1>Recent Posts</h1>
- <ul id="recent_posts">
- {{ range first .Site.Params.sidebarRecentLimit .Site.Pages }}
- <li class="post">
- <a href="{{ .RelPermalink }}">{{ .Title }}</a>
- </li>
- {{ end }}
- </ul>
- </section>
+ {{ with .Site.Params.sidebarRecentLimit }}
+ {{ if not (eq $.Site.Params.sidebarRecentLimit 0) }}
+ <section class="even">
+ <h1>Recent Posts</h1>
+ <ul id="recent_posts">
+ {{ range first $.Site.Params.sidebarRecentLimit $.Site.Pages }}
+ <li class="post">
+ <a href="{{ .RelPermalink }}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+ </ul>
+ </section>
+ {{ end }}
{{ end }}
</aside>
diff --git a/sample-config.toml b/sample-config.toml
index 1c53eb8..d70c54f 100644
--- a/sample-config.toml
+++ b/sample-config.toml
@@ -148,11 +148,17 @@ post = "/blog/:year-:month-:day-:title/" # change the post URL to look like the
notFoundText = """Please either go back or use the navigation/sidebar menus.
"""
- # Set to true to hide ReadingTime on posts
- disableReadingTime = false
+ # Set to true to hide ReadingTime on posts
+ disableReadingTime = false
- # Set to true to disable downloading of remote Google fonts
- disableGoogleFonts = false
+ # Set to true to disable downloading of remote Google fonts
+ disableGoogleFonts = false
+
+ # Generate taxonomy pages
+ generateTaxonomyList = true
+
+ # This is not needed unless alphabetical sort is needed
+ # sortTaxonomyAlphabetical = true
# Blackfriday is Hugo's markdown engine. Options are at: https://gohugo.io/overview/configuration/ (scroll down to "Configure Blackfriday rendering")