Skip to content

Commit

Permalink
Use authors taxonomy and list all posts on a draft user's page (#306)
Browse files Browse the repository at this point in the history
* add taxonomies to config.toml

* change blog posts to use 'authors' instead of 'author'; add author 'Jane Doe'

* draft for user page listing all user posts

* change from using 'author' to 'authors'

* remove space before comma for multiple authors

* remove authors/list.html to get same look like tags/categories listing
  • Loading branch information
mgisbers authored Aug 4, 2021
1 parent 0f9faf7 commit 965e6c2
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ paginate = 10
title = "From our blog"
subtitle = "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo."
hide_summary = false

[taxonomies]
category = "categories"
tag = "tags"
author = "authors"
2 changes: 1 addition & 1 deletion exampleSite/content/blog/categories-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ date = "2021-08-01T21:29:20+02:00"
tags = ["golang", "programming", "theme", "hugo"]
categories = ["programming","lorem","pseudo"]
banner = "img/banners/banner-4.jpg"
author = "John Doe"
authors = ["John Doe"]
+++

I'm a post with multiple categories in the frontmatter:
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/blog/creating-a-new-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tags = ["theme"]
categories = ["starting"]
description = "This tutorial will show you how to create a simple theme in Hugo. I assume that you are familiar with HTML, the bash command line, and that you are comfortable using Markdown to format content."
banner = "img/banners/banner-1.jpg"
authors = ["Jane Doe"]
+++

## Introduction
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/blog/linked-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ date = "2015-10-02T21:49:20+02:00"
tags = ["golang", "programming", "theme", "hugo"]
categories = ["programming"]
banner = "img/banners/banner-4.jpg"
author = "John Doe"
authors = ["John Doe","Jane Doe"]
+++

I'm a linked post in the menu. You can add other posts by adding the following line to the frontmatter:
Expand Down
4 changes: 2 additions & 2 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
<div class="clearfix">
<p class="author-category">
{{ if isset .Params "author" }}
{{ i18n "authorBy" }} <a href="#">{{ .Params.author }}</a>
{{ if isset .Params "authors" }}
{{ i18n "authorBy" }} {{ range $index, $author := .Params.authors }}{{ if $index }}, {{ end }}<a href="{{ (printf "%s/%s" ("authors" | relURL) ($author | urlize)) }}">{{ $author }}</a>{{ end }}
{{ end }}
{{ if isset .Params "categories" }}
{{ if gt (len .Params.categories) 0 }}
Expand Down
4 changes: 3 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

{{ if or .Params.author .Params.date }}
<p class="text-muted text-uppercase mb-small text-right">
{{ if .Params.author }}{{ i18n "authorBy" }} <a href="#">{{ .Params.author }}</a>{{ end }}
{{ if isset .Params "authors" }}
{{ i18n "authorBy" }} {{ range $index, $author := .Params.authors }}{{ if $index }}, {{ end }}<a href="{{ (printf "%s/%s" ("authors" | relURL) ($author | urlize)) }}">{{ $author }}</a>{{ end }}
{{ end }}
{{ if and .Params.author .Params.date }} | {{ end }}
{{ if .Params.date }}{{ .Date.Format .Site.Params.date_format }}{{ end }}
</p>
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/recent_posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ <h2>{{ .Site.Params.recent_posts.title | markdownify }}</h2>
<div class="content">
<h4><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
<p class="author-category">
{{ with .Params.author }}
{{ i18n "authorBy" }} <a href="#">{{ . }}</a>
{{ if isset .Params "authors" }}
{{ i18n "authorBy" }} {{ range $index, $author := .Params.authors }}{{ if $index }}, {{ end }}<a href="{{ (printf "%s/%s" ("authors" | relURL) ($author | urlize)) }}">{{ $author }}</a>{{ end }}
{{ end }}
{{ i18n "publishedOn" }} {{ .Date.Format .Site.Params.date_format }}
</p>
Expand Down

0 comments on commit 965e6c2

Please sign in to comment.