summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-05-19 01:44:38 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-05-19 01:44:38 +0200
commitd9611790b73a4b4623c2516e3dbf5e3523761f53 (patch)
tree2546abe710e3117e3e307358832932334cd674c8
parentbd4bb369895e07ca6b4eed1439e8ca7a93ba4802 (diff)
downloadgohugo-theme-ed-d9611790b73a4b4623c2516e3dbf5e3523761f53.tar.gz
Add webmanifest
-rw-r--r--.gitattributes2
-rw-r--r--exampleSite/config.toml19
-rw-r--r--layouts/_default/home.json.json2
-rw-r--r--layouts/_default/home.manifest.webmanifest25
-rw-r--r--layouts/partials/head.html2
-rw-r--r--static/manifest.webmanifest8
6 files changed, 45 insertions, 13 deletions
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 @@
<link rel="icon" href="{{ site.Params.assets.favicon | default "favicon.ico" | relURL }}" sizes="any"><!-- 32×32 -->
<link rel="icon" href="{{ site.Params.assets.svgicon | default "icon.svg" | relURL }}" type="image/svg+xml">
<link rel="apple-touch-icon" href="{{ site.Params.assets.apple_touch_icon | default "apple-touch-icon.png" | relURL }}"><!-- 180×180 -->
- <link rel="manifest" href="{{ site.Params.assets.webmanifest | default "manifest.webmanifest" | relURL }}">
+ <link rel="manifest" href="{{ "manifest.webmanifest" | relURL }}">
{{- /* 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" }
- ]
-}