From f8b84de3f852bfa04e973592fa5af8c5f00d2383 Mon Sep 17 00:00:00 2001 From: Dave A-W Date: Sun, 26 Apr 2020 23:58:15 +0800 Subject: [PATCH] Support favicon color theming (#260) --- exampleSite/config.toml | 42 +++++++++++++++++++ .../posts/theme-documentation-basics.en.md | 15 +++++++ .../posts/theme-documentation-basics.fr.md | 15 +++++++ .../posts/theme-documentation-basics.zh-cn.md | 15 +++++++ layouts/partials/head/link.html | 22 ++++++---- layouts/partials/head/meta.html | 13 ++++-- 6 files changed, 112 insertions(+), 10 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 632987a..902d95b 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -95,6 +95,20 @@ enableEmoji = true description = "About LoveIt Theme" # site keywords keywords = ["Theme", "Hugo"] + # App icon config + [languages.en.params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" # Search config [languages.en.params.search] enable = true @@ -270,6 +284,20 @@ enableEmoji = true description = "关于 LoveIt 主题" # 网站关键词 keywords = ["Theme", "Hugo"] + # App icon config + [languages.zh-cn.params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" # 搜索配置 [languages.zh-cn.params.search] enable = true @@ -441,6 +469,20 @@ enableEmoji = true description = "À propos du thème LoveIt" # site keywords keywords = ["Thème", "Hugo"] + # App icon config + [languages.fr.params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" # Search config [languages.fr.params.search] enable = true diff --git a/exampleSite/content/posts/theme-documentation-basics.en.md b/exampleSite/content/posts/theme-documentation-basics.en.md index a6808ac..f98cb5f 100644 --- a/exampleSite/content/posts/theme-documentation-basics.en.md +++ b/exampleSite/content/posts/theme-documentation-basics.en.md @@ -203,6 +203,21 @@ Note that some of these parameters are explained in details in other sections of # {{< version 0.2.0 >}} date format dateFormat = "2006-01-02" + # {{< version 0.2.0 >}} App icon config + [params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" + # {{< version 0.2.0 >}} Search config [params.search] enable = true diff --git a/exampleSite/content/posts/theme-documentation-basics.fr.md b/exampleSite/content/posts/theme-documentation-basics.fr.md index fc1a13e..6c09870 100644 --- a/exampleSite/content/posts/theme-documentation-basics.fr.md +++ b/exampleSite/content/posts/theme-documentation-basics.fr.md @@ -208,6 +208,21 @@ Note that some of these parameters are explained in details in other sections of # {{< version 0.2.0 >}} date format dateFormat = "2006-01-02" + # {{< version 0.2.0 >}} App icon config + [params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" + # {{< version 0.2.0 >}} Search config [params.search] enable = true diff --git a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md index cc9105b..c889c74 100644 --- a/exampleSite/content/posts/theme-documentation-basics.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics.zh-cn.md @@ -206,6 +206,21 @@ hugo # {{< version 0.2.0 >}} 日期格式 dateFormat = "2006-01-02" + # {{< version 0.2.0 >}} App icon config + [params.app] + # optional site title override for the app when added to an iOS home screen or Android launcher + title = "LoveIt App" + # whether to omit favicon resource links + noFavicon = true + # modern SVG favicon to use in place of older style .png and .ico files + svgFavicon = 'favicon.svg' + # Android browser color theming + themeColor = "#ffffff" + # Safari mask icon color + iconColor = "#5bbad5" + # Windows v8-10 tile color + tileColor = "#da532c" + # {{< version 0.2.0 >}} 搜索配置 [params.search] enable = true diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html index 368a3d4..eb7c8a2 100644 --- a/layouts/partials/head/link.html +++ b/layouts/partials/head/link.html @@ -1,14 +1,22 @@ {{- $cdn := .Scratch.Get "cdn" | default dict -}} {{- $fingerprint := .Scratch.Get "fingerprint" -}} - - - - - - - +{{- if not $.Site.Params.app.noFavicon -}} + {{- with $.Site.Params.app.svgFavicon -}} + + {{- else -}} + + + + {{- end -}} + + {{- with $.Site.Params.app.iconColor -}} + + {{- end -}} + +{{- end -}} + {{- if .PrevInSection -}} {{- end -}} diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html index 56fcd32..88457cb 100644 --- a/layouts/partials/head/meta.html +++ b/layouts/partials/head/meta.html @@ -1,6 +1,13 @@ {{- template "_internal/opengraph.html" . -}} {{- template "_internal/twitter_cards.html" . -}} -{{- hugo.Generator -}} - - + + + +{{- with .Site.Params.app.themeColor -}} + +{{- end -}} + +{{- with .Site.Params.app.tileColor -}} + +{{- end -}}