From 5344a15889ee292cd0082bae63f847d7d9a27b84 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 14 May 2022 11:28:47 +0200 Subject: Add humans.txt support --- exampleSite/config.toml | 57 ++++++++++++++++++++++++++++++++++++--- layouts/index.humanstxt.txt | 36 +++++++++++++++++++++++++ layouts/partials/author.html | 1 + layouts/partials/head.html | 1 + layouts/partials/team-member.html | 5 ++++ layouts/robots.txt | 2 +- 6 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 layouts/index.humanstxt.txt create mode 100644 layouts/partials/team-member.html 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 @@ + {{ block "title" . }}{{ if .IsHome }}{{ site.Title }}{{ else }}{{ with .Params.Title }}{{ . }} - {{ end }}{{ site.Title }}{{ end }}{{ end }} 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 }} -- cgit v1.2.3