Skip to content
Permalink
Browse files

feat: automatically generate website icons

See #1439
  • Loading branch information
gcushen committed Dec 28, 2019
1 parent 6c86640 commit ce7501322873627e9e2cbe80e9bee6d4b4711006
File renamed without changes.
@@ -6,11 +6,11 @@
"theme_color": "{{ $scr.Get "primary" }}",
"background_color": "{{ $scr.Get "primary" }}",
"icons": [{
"src": "../img/icon-192.png",
"src": "{{ (partial "functions/get_icon" 192).RelPermalink }}",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "../img/icon-512.png",
"src": "{{ (partial "functions/get_icon" 512).RelPermalink }}",
"sizes": "512x512",
"type": "image/png"
}],
@@ -0,0 +1,7 @@
{{/* Function to get website icon image. */}}
{{/* Input: size (int) */}}
{{/* Output: resource (obj) */}}

{{ $icon := resources.GetMatch "images/icon.png" }}
{{ $icon_resized := $icon.Fill (printf "%sx%s Center" (string .) (string .)) }}
{{ return $icon_resized }}
@@ -10,7 +10,7 @@

{{ $author := partial "functions/get_author_name" $page }}
{{ $publisher := site.Params.org_name | default site.Title }}
{{ $logo_url := printf "img/%s" (site.Params.logo | default "icon-512.png") | absURL }}
{{ $logo_url := (printf "img/%s" (site.Params.logo | absURL)) | default (partial "functions/get_icon" 512).Permalink }}

<script type="application/ld+json">
{
@@ -142,8 +142,8 @@
{{ end }}

<link rel="manifest" href="{{ "index.webmanifest" | relLangURL }}">
<link rel="icon" type="image/png" href="{{ "img/icon-32.png" | relURL }}">
<link rel="apple-touch-icon" type="image/png" href="{{ "img/icon-192.png" | relURL }}">
<link rel="icon" type="image/png" href="{{(partial "functions/get_icon" 32).RelPermalink}}">
<link rel="apple-touch-icon" type="image/png" href="{{(partial "functions/get_icon" 192).RelPermalink}}">

<link rel="canonical" href="{{ .Permalink }}">

@@ -163,7 +163,7 @@
{{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }}
{{ $twitter_card = "summary" }}
{{ else }}
{{ $og_image = "img/icon-192.png" | absURL }}
{{ $og_image = (partial "functions/get_icon" 512).Permalink }}
{{ $twitter_card = "summary" }}
{{ end }}
{{ $scr.Set "og_image" $og_image }}{{/* Set `og_image` globally for `rss.xml`. */}}
@@ -10,8 +10,8 @@
<meta name="generator" content="Source Themes Academic {{ site.Data.academic.version }}">

<link rel="manifest" href="{{ "index.webmanifest" | relLangURL }}">
<link rel="icon" type="image/png" href="{{ "img/icon-32.png" | relURL }}">
<link rel="apple-touch-icon" type="image/png" href="{{ "img/icon-192.png" | relURL }}">
<link rel="icon" type="image/png" href="{{(partial "functions/get_icon" 32).RelPermalink}}">
<link rel="apple-touch-icon" type="image/png" href="{{(partial "functions/get_icon" 192).RelPermalink}}">

<link rel="canonical" href="{{ .Permalink }}">

Binary file not shown.
Binary file not shown.

0 comments on commit ce75013

Please sign in to comment.
You can’t perform that action at this time.