summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-14 11:28:47 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-14 11:28:47 +0200
commit5344a15889ee292cd0082bae63f847d7d9a27b84 (patch)
tree44aa8b0fb14f1e914610c26a1a37bd5d3f4b0b22
parent3858a4289a8a0e3f301975e3071fc2efb82334a0 (diff)
downloadgohugo-theme-ed-5344a15889ee292cd0082bae63f847d7d9a27b84.tar.gz
Add humans.txt support
-rw-r--r--exampleSite/config.toml57
-rw-r--r--layouts/index.humanstxt.txt36
-rw-r--r--layouts/partials/author.html1
-rw-r--r--layouts/partials/head.html1
-rw-r--r--layouts/partials/team-member.html5
-rw-r--r--layouts/robots.txt2
6 files changed, 98 insertions, 4 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 4bf5dcb..568e2bd 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -7,6 +7,55 @@ theme = ['github.com/sergeyklay/gohugo-theme-ed']
resourceDir = '../resources'
enableRobotsTXT = true
+[outputs]
+ # TODO:
+ # home = [ "HTML", "RSS", "Atom", "JSON", "humanstxt" ]
+ # section = [ "HTML", "RSS", "Atom" ]
+ home = [ 'HTML', 'humanstxt' ]
+
+[outputFormats.humanstxt]
+ baseName = 'humans'
+ isPlainText = true
+ mediaType = 'text/plain'
+
+# TODO:
+# [outputFormats.Atom]
+# mediaType = "application/atom"
+# baseName = "feed"
+# isPlainText = false
+
+# Possible 'Author' formats are:
+#
+# [author]
+# name = 'Foo Bar'
+# email = 'john@example.com'
+# github = '@john_doe'
+# location = 'Kyiv, Ukraine'
+# ========= OR ===========
+#
+# [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'
+[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
@@ -45,9 +94,10 @@ enableRobotsTXT = true
[social]
# Facebook Page Admin ID for Domain Insights
facebook_admin = ''
+ # Facebook Page ID
facebook_id = ''
-# https://gohugo.io/content-management/menus/
+# For more see https://gohugo.io/content-management/menus/
[menu]
[[menu.main]] # sections in the website sidebar
identifier = 'home' # section id
@@ -82,12 +132,13 @@ enableRobotsTXT = true
[menu.main.params]
external = true
-# https://gohugo.io/getting-started/configuration-markup/
+# For more see https://gohugo.io/getting-started/configuration-markup/
[markup]
defaultMarkdownHandler = 'goldmark'
[markup.highlight]
- # Syntax highlight style, see https://xyproto.github.io/splash/docs/
+ # Syntax highlight style.
+ # For more see https://xyproto.github.io/splash/docs/
style = 'emacs'
[markup.goldmark]
diff --git a/layouts/index.humanstxt.txt b/layouts/index.humanstxt.txt
new file mode 100644
index 0000000..d8aec86
--- /dev/null
+++ b/layouts/index.humanstxt.txt
@@ -0,0 +1,36 @@
+{{/* TODO: Translate me */}}
+CONGRATULATIONS, you found my humans.txt file!
+
+───────────────────────────────────────────────────────────────────────────────
+
+ /* TEAM */
+{{ if 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 -}}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
+
+ /* SITE */
+
+ Last update: ???
+ Language: Russian, English
+ Doctype: HTML5
+ Standards: HTML5, CSS3, Open Graph protocol, Schema.org
+ Components: Hugo, jQuery, Ed Theme
diff --git a/layouts/partials/author.html b/layouts/partials/author.html
index 6de4feb..efb1dbd 100644
--- a/layouts/partials/author.html
+++ b/layouts/partials/author.html
@@ -22,6 +22,7 @@
{{- end }}
{{- end }}
{{- delimit ($.Scratch.GetSortedMapValues "names") ", " }}
+ {{- $.Scratch.Delete "names" -}}
{{- end }}
{{- end -}}
{{- end -}}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index da95aa5..abb4cbe 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -10,6 +10,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0,shrink-to-fit=no">
<link rel="canonical" href="{{ .Permalink }}">
+ <link type="text/plain" rel="author" href="{{ "humans.txt" | absURL }}">
<title>{{ block "title" . }}{{ if .IsHome }}{{ site.Title }}{{ else }}{{ with .Params.Title }}{{ . }} - {{ end }}{{ site.Title }}{{ end }}{{ end }}</title>
<meta name="description" content="{{ $description }}">
diff --git a/layouts/partials/team-member.html b/layouts/partials/team-member.html
new file mode 100644
index 0000000..917e97f
--- /dev/null
+++ b/layouts/partials/team-member.html
@@ -0,0 +1,5 @@
+
+ Author: {{ .Name }}
+ Contact: {{ .Email }}
+ GitHub: {{ .Github }}
+ From: {{ .Location }}
diff --git a/layouts/robots.txt b/layouts/robots.txt
index dbc405e..c59438e 100644
--- a/layouts/robots.txt
+++ b/layouts/robots.txt
@@ -1,9 +1,9 @@
-# TODO: Does not work
{{- $url := urls.Parse ("/" | absURL) -}}
# robots.txt file for "{{ site.Title }}" website, {{ $url.Host }}
User-agent: *
{{- if eq (getenv "HUGO_ENV") "production" | or (eq site.Params.env "production") }}
Allow: /
+
# TODO: implement sitemap.xml
# Sitemap: {{ "stemap.xml" | absURL }}
{{- else }}