summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-15 11:48:32 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-15 11:48:32 +0200
commit3ba00d4b693f502ba3546103012f7b700286ff7d (patch)
tree98d021a0f74555b1d28e96c3128ec273bfdddfb0
parent5344a15889ee292cd0082bae63f847d7d9a27b84 (diff)
downloadgohugo-theme-ed-3ba00d4b693f502ba3546103012f7b700286ff7d.tar.gz
Rework humans.txt generation
-rw-r--r--exampleSite/config.toml20
-rw-r--r--layouts/index.humanstxt.txt27
-rw-r--r--layouts/partials/team-member.html8
3 files changed, 16 insertions, 39 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 568e2bd..3b0953c 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -24,14 +24,7 @@ enableRobotsTXT = true
# baseName = "feed"
# isPlainText = false
-# Possible 'Author' formats are:
-#
-# [author]
-# name = 'Foo Bar'
-# email = 'john@example.com'
-# github = '@john_doe'
-# location = 'Kyiv, Ukraine'
-# ========= OR ===========
+# Possible 'Author' format is:
#
# [author]
# [author.john_doe]
@@ -44,23 +37,20 @@ enableRobotsTXT = true
# email = 'jane@example.com'
# github = '@jane_doe'
# location = 'Lviv, Ukraine'
+#
+# TODO: Mention format in docs
[author]
[author.john_doe]
name = 'John Doe'
email = 'john@example.com'
github = '@john_doe'
location = 'Kyiv, Ukraine'
- [author.jane_doe]
- name = 'Jane Doe'
- email = 'jane@example.com'
- github = '@jane_doe'
- location = 'Lviv, Ukraine'
[languages]
[languages.en]
weight = 1
- # "rtl" for Right-To-Left languages
- languageDirection = "ltr"
+ languageDirection = 'ltr'
+ languageName = 'English'
[params]
# Site author name. For multiple authors use: ['Me', 'You']
diff --git a/layouts/index.humanstxt.txt b/layouts/index.humanstxt.txt
index d8aec86..dd475bd 100644
--- a/layouts/index.humanstxt.txt
+++ b/layouts/index.humanstxt.txt
@@ -1,27 +1,14 @@
-{{/* TODO: Translate me */}}
CONGRATULATIONS, you found my humans.txt file!
───────────────────────────────────────────────────────────────────────────────
- /* TEAM */
-{{ if site.Author }}
+{{ with site.Author }}
{{- $author_type := (printf "%T" site.Author) }}
{{- if (or (eq $author_type "map[string]string") (eq $author_type "map[string]interface {}")) }}
- {{- range $i, $author := site.Author }}
- {{- $name_type := (printf "%T" $author) }}
- {{- if (eq $name_type "maps.Params") }}
- {{- $.Scratch.Set "name" ($author.Get "name") }}
- {{- $.Scratch.Set "email" ($author.Get "email") }}
- {{- $.Scratch.Set "github" ($author.Get "github") }}
- {{- $.Scratch.Set "location" ($author.Get "location") }}
- {{- partial "team-member.html" . -}}
- {{ else }}
- {{- $.Scratch.Set "name" site.Author.name }}
- {{- $.Scratch.Set "email" site.Author.email }}
- {{- $.Scratch.Set "github" site.Author.github }}
- {{- $.Scratch.Set "location" site.Author.location }}
- {{- partial "team-member.html" . }}
- {{- break -}}
+ /* TEAM */
+ {{ range $i, $member := site.Author }}
+ {{- if (eq (printf "%T" $member) "maps.Params") }}
+ {{- partial "team-member.html" (dict "context" . "member" $member) -}}
{{- end }}
{{- end }}
{{- end }}
@@ -29,8 +16,8 @@ CONGRATULATIONS, you found my humans.txt file!
/* SITE */
- Last update: ???
- Language: Russian, English
+ Last update: {{ now.Format "2006-01-02" }}
+ Language: {{ range $i, $l := site.Languages }}{{ if $i }}, {{ end }}{{ .LanguageName }}{{ end }}
Doctype: HTML5
Standards: HTML5, CSS3, Open Graph protocol, Schema.org
Components: Hugo, jQuery, Ed Theme
diff --git a/layouts/partials/team-member.html b/layouts/partials/team-member.html
index 917e97f..f425f33 100644
--- a/layouts/partials/team-member.html
+++ b/layouts/partials/team-member.html
@@ -1,5 +1,5 @@
- Author: {{ .Name }}
- Contact: {{ .Email }}
- GitHub: {{ .Github }}
- From: {{ .Location }}
+ Author: {{ .context.Name | default "-" }}
+ Contact: {{ .context.Email | default "-" }}
+ GitHub: {{ .context.GitHub | default "-" }}
+ From: {{ .context.Location | default "-" }}