Merge pull request #3 from Reijnn/master

Added theme-color param for mobile devices
This commit is contained in:
Djordje Atlialp 2019-03-05 18:50:58 +01:00 committed by GitHub
commit cf9126f617
5 changed files with 50 additions and 24 deletions

View File

@ -52,6 +52,19 @@ If you don't want to make any radical changes, it's the best option, because you
```
$ git submodule add https://github.com/rhazdon/hugo-theme-hello-friend-ng.git themes/hello-friend-ng
```
### Favicon
Use [RealFaviconGenerator](https://realfavicongenerator.net/) to generate these files, put them into your site's static folder:
- android-chrome-192x192.png
- android-chrome-512x512.png
- apple-touch-icon.png
- favicon-16x16.png
- favicon-32x32.png
- favicon.ico
- mstile-150x150.png
- safari-pinned-tab.svg
- site.webmanifest
## How to configure

View File

@ -3,6 +3,7 @@
const getTheme = window.localStorage && window.localStorage.getItem("theme");
const themeToggle = document.querySelector(".theme-toggle");
const isDark = getTheme === "dark";
var metaThemeColor = document.querySelector("meta[name=theme-color]");
if (getTheme !== null) {
document.body.classList.toggle("dark-theme", isDark);
@ -15,4 +16,7 @@ themeToggle.addEventListener("click", () => {
"theme",
document.body.classList.contains("dark-theme") ? "dark" : "light",
);
document.body.classList.contains("dark-theme") ?
metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
;
});

View File

@ -74,6 +74,7 @@ disableHugoGeneratorInject = false
contentTypeName = "posts"
# Default theme "light" or "dark"
defaultTheme = "dark"
themeColor = "#252627"
[params.logo]
logoText = "$ cd /home/"

View File

@ -2,5 +2,6 @@
<link rel="icon" type="image/png" sizes="32x32" href="{{"favicon-32x32.png" | relURL}}">
<link rel="icon" type="image/png" sizes="16x16" href="{{"favicon-16x16.png" | relURL}}">
<link rel="manifest" href="{{"site.webmanifest" | relURL}}">
<link rel="mask-icon" href="{{"safari-pinned-tab.svg" | relURL}}" color="{{.Site.Params.themeColor}}">
<link rel="mask-icon" href="{{"safari-pinned-tab.svg" | relURL}}" color="#252627">
<link rel="shortcut icon" href="{{"favicon.ico" | relURL}}">
<meta name="theme-color" content="#252627">

View File

@ -1,33 +1,37 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="author" content="{{ if .Params.author }}{{ .Params.author }}{{ else }}{{ range .Site.Author }}{{ . }} {{ end }}{{ end }}">
<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.Subtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}"/>
<meta name="keywords" content="{{ .Site.Params.keywords }}"/>
<meta name="robots" content="noodp"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author"
content="{{ if .Params.author }}{{ .Params.author }}{{ else }}{{ range .Site.Author }}{{ . }} {{ end }}{{ end }}">
<meta name="description"
content="{{ if .IsHome }}{{ .Site.Params.homeSubtitle }}{{ else }}{{ .Summary | plainify }}{{ end }}" />
<meta name="keywords" content="{{ .Site.Params.keywords }}" />
<meta name="robots" content="noodp" />
<link rel="canonical" href="{{ .Permalink }}" />
{{ block "title" . }}
<title>
{{ if .IsHome }}
{{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }} {{ end }}
{{ else }}
{{ .Title }} :: {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }}{{ end }}
{{ end }}
</title>
<title>
{{ if .IsHome }}
{{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }} {{ end }}
{{ else }}
{{ .Title }} :: {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }}{{ end }}
{{ end }}
</title>
{{ end }}
<!-- CSS -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Source+Code+Pro" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.2.1/css/flag-icon.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Source+Code+Pro" rel="stylesheet"
type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.2.1/css/flag-icon.min.css" rel="stylesheet"
type="text/css">
{{ $style := resources.Get "scss/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
{{ range $val := $.Site.Params.customCSS }}
{{ if gt (len $val) 0 }}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
{{ if gt (len $val) 0 }}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
{{ end }}
<!-- Icons -->
@ -36,20 +40,23 @@
{{- template "_internal/schema.html" . }}
{{- template "_internal/twitter_cards.html" . }}
{{ range .Params.categories }}<meta property="article:section" content="{{ . }}" />{{ end }}
{{ if isset .Params "date" }}<meta property="article:published_time" content="{{ time .Date }}" />{{ end }}
{{ range .Params.categories }}
<meta property="article:section" content="{{ . }}" />{{ end }}
{{ if isset .Params "date" }}
<meta property="article:published_time" content="{{ time .Date }}" />{{ end }}
<!-- RSS -->
{{ if .RSSLink }}
<link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
<link href="{{ .Site.RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ end }}
<!-- JSON Feed -->
{{ if .OutputFormats.Get "json" }}
<link href="{{ if .OutputFormats.Get "json" }}{{ .Site.BaseURL }}feed.json{{ end }}" rel="alternate" type="application/json" title="{{ .Site.Title }}" />
<link href="{{ if .OutputFormats.Get "json" }}{{ .Site.BaseURL }}feed.json{{ end }}" rel="alternate"
type="application/json" title="{{ .Site.Title }}" />
{{ end }}
<!-- Custom head tags -->
{{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }}
{{- end }}
{{ partial "extra-head.html" . }}
{{- end }}