Skip to content

Commit

Permalink
feat: add author display and show author configuration. close #54
Browse files Browse the repository at this point in the history
  • Loading branch information
tomowang committed Aug 27, 2024
1 parent 3131831 commit 21ec731
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Some of the configuration options are:
* `params.social_media`: social media links shown in the footer
* `params.search`: search settings
* `params.author`: author used in the JSON-LD
* `params.showAuthor`: show author name in article list and article page
* `params.jsonLD`: enable or disable JSON-LD (default disabled)
* `params.pwa`: enable or disable PWA (default disabled)

Expand Down
7 changes: 7 additions & 0 deletions assets/icons/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ showReadingTime = true
# use structure json-ld for articles
jsonLD = false

showAuthor = false

[author]
name = "Hugo Author"
email = "user@example.com"
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ contentTypeName = "post"

jsonLD = true

showAuthor = true

[author]
name = "Xiaoliang Wang"
email = "user@example.com"
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/post/image-process/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+++
author = "Hugo Authors"
# author = "Hugo Authors"
title = "Image Process"
date = "2023-12-01"
description = "Demo of Hugo's image processing"
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/content/post/image-process/index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+++
author = "Hugo Authors"
# author = "Hugo Authors"
title = "图片处理"
date = "2023-12-01"
description = "关于Hugo中图片处理的示例"
Expand Down
1 change: 1 addition & 0 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h2 class="text-4xl font-semibold text-slate-800 dark:text-slate-200">
{{ partial "block/taxonomies.html" .}}

{{ partial "block/time.html" . }}
{{ partial "block/author.html" . }}
</div>
</article>
{{ end }}
Expand Down
1 change: 1 addition & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h2 class="my-4 text-large text-slate-600 dark:text-slate-300">
{{ partial "block/taxonomies.html" .}}

{{ partial "block/time.html" . }}
{{ partial "block/author.html" . }}

{{ if or .Params.Toc $.Site.Params.Toc }}
{{ if ne .Params.Toc false }}
Expand Down
21 changes: 21 additions & 0 deletions layouts/partials/block/author.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Site.Params.showAuthor -}}
{{- $author := "" -}}

{{- if .Params.author -}}
{{- $author = .Params.author -}}
{{- else if and .Site.Params.Author .Site.Params.Author.name -}}
{{- $author = .Site.Params.Author.name -}}
{{- end -}}

{{- if $author -}}
<div class="flex flex-col gap-y-1 md:flex-row md:gap-y-0 md:gap-x-4 text-slate-500 dark:text-slate-300">
<div class="flex flex-row text-base gap-x-1">
<i class="h-6 w-6 flex-none">
{{ partial "icon.html" "user" }}
</i>
<span>{{ $author }}</span>
</div>
</div>
{{- end -}}

{{- end -}}

0 comments on commit 21ec731

Please sign in to comment.