From d9611790b73a4b4623c2516e3dbf5e3523761f53 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Thu, 19 May 2022 01:44:38 +0200 Subject: Add webmanifest --- .gitattributes | 2 -- exampleSite/config.toml | 19 ++++++++++++++++++- layouts/_default/home.json.json | 2 +- layouts/_default/home.manifest.webmanifest | 25 +++++++++++++++++++++++++ layouts/partials/head.html | 2 +- static/manifest.webmanifest | 8 -------- 6 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 layouts/_default/home.manifest.webmanifest delete mode 100644 static/manifest.webmanifest diff --git a/.gitattributes b/.gitattributes index ed08374..e327836 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,8 +18,6 @@ go.sum export-ignore exampleSite/** linguist-vendored resources/_gen/** linguist-vendored -*.webmanifest diff=json linguist-language=JSON - LICENSE text eol=lf README.md text eol=lf diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4fcc7f1..ae9d232 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -17,7 +17,7 @@ disableKinds = ['RSS'] [outputs] # TODO: # section = [ "HTML", "Atom" ] - home = [ 'HTML', 'Atom', 'FEED', 'JSON', 'humanstxt' ] + home = [ 'HTML', 'Atom', 'FEED', 'JSON', 'MANIFEST', 'humanstxt' ] # Atom feed. # For more see: https://validator.w3.org/feed/docs/atom.html#whatIsAtom @@ -60,6 +60,21 @@ disableKinds = ['RSS'] isHTML = false noUgly = false +# The .webmanifest extension is specified in the Media type registration +# section of the specification (the response of the manifest file should +# return Content-Type: application/manifest+json). +# +# For more see: https://w3c.github.io/manifest/#media-type-registration= +[outputFormats.MANIFEST] + name = 'Manifest' + mediaType = 'application/manifest+json' + baseName = 'manifest' + rel = 'manifest' + isPlainText = true + isHTML = false + noUgly = false + notAlternative = true + # For more see: https://gohugo.io/templates/output-formats/ [outputFormats.humanstxt] mediaType = 'text/plain' @@ -75,6 +90,8 @@ disableKinds = ['RSS'] suffixes = ['xml'] [mediaTypes.'application/feed+json'] suffixes = ['json'] + [mediaTypes.'application/manifest+json'] + suffixes = ['webmanifest'] [author] name = 'John Doe' diff --git a/layouts/_default/home.json.json b/layouts/_default/home.json.json index a86e88d..6df1514 100644 --- a/layouts/_default/home.json.json +++ b/layouts/_default/home.json.json @@ -1,6 +1,6 @@ { "version": "https://jsonfeed.org/version/1.1", - "title": {{ (printf "%s JSON Feed" site.Title) | jsonify }}, + "title": {{ (printf "%s JSON Feed" site.Title) | htmlUnescape | jsonify }}, "home_page_url": {{ site.BaseURL | absURL | jsonify }}, {{ with .OutputFormats.Get "JSON" }}"feed_url": {{.Permalink | absURL | jsonify }},{{ end }} {{ with site.Params.description}}"description": {{site.Params.description | jsonify}},{{end}} diff --git a/layouts/_default/home.manifest.webmanifest b/layouts/_default/home.manifest.webmanifest new file mode 100644 index 0000000..5e78f2a --- /dev/null +++ b/layouts/_default/home.manifest.webmanifest @@ -0,0 +1,25 @@ +{ + "name": {{ site.Title | htmlUnescape | jsonify }}, + {{ with site.Params.tagline }}"short_name": {{ . | htmlUnescape | jsonify }},{{end}} + {{with site.Params.description}}"description": {{ . | htmlUnescape | jsonify }},{{end}} + {{ with site.LanguageCode }}"lang": {{ . | jsonify }},{{ end }} + "start_url": "/index.html", + "display": "fullscreen", + "orientation": "natural", + "dir": "ltr", + "shortcuts": [ {{ range $index, $m := site.Menus.main }} {{ if or (lt .Weight 900) site.IsServer }} + {{ if $index }}, {{ end }} + { + "name": {{ $m.Name | jsonify}}, + "short_name" : {{ $m.Identifier | jsonify}}, + "url": {{ $m.URL | jsonify }} + }{{ end}}{{ end}} + ], + "icons": [{{ $t := slice 144 192 256 512}}{{ range $t }} + { + "src": "/img/yy{{.}}.png", + "type": "image/png", + "sizes": "{{.}}x{{.}}" + }{{ if ne . 512 }},{{end }}{{- end}} + ] +} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b0f1e58..3531d4f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -18,7 +18,7 @@ - + {{- /* RSS */}} {{ range .AlternativeOutputFormats }} diff --git a/static/manifest.webmanifest b/static/manifest.webmanifest deleted file mode 100644 index a43b334..0000000 --- a/static/manifest.webmanifest +++ /dev/null @@ -1,8 +0,0 @@ -{ - "short_name": "Ed.", - "name": "Ed: a Hugo theme for minimal editions", - "icons": [ - { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" }, - { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" } - ] -} -- cgit v1.2.3