Commit cab86aa3 authored by Laura Kalbag's avatar Laura Kalbag
Browse files

Rename colourTheme files so they correspond to config options

Towards #164
parent 9038e1aa
{{/* look in static folder to see if favicon files exist, if they do, link to them using the relevant meta */}}
{{- /* look in static folder to see if favicon files exist, if they do, link to them using the relevant meta */ -}}
{{- /* if they don’t, use a colour themed default icon */ -}}
{{- /* get chosen colour */ -}}
{{ $colour := $.Site.Params.colour }}
{{- /* get the theme colour */ -}}
{{- /* set favicon colour to storm-blue by default*/ -}}
{{- $faviconFolder := "stormBlue"}}
{{- $faviconColour := .Site.Data.themeColoursStormBlue.colour50 }}
{{- $themeColour := .Site.Data.themeColoursStormBlue.colour80 }}
{{ $colourTheme := partial "get-param/colour-theme.html" . }}
{{- /* replace the favicon colour from the colour data file if the chosen colour is not storm-blue */ -}}
{{- if eq $colour "amber-orange" }}
{{- $faviconFolder = "amberOrange"}}
{{- $faviconColour = .Site.Data.themeColoursAmberOrange.colour50 }}
{{- $themeColour = .Site.Data.themeColoursAmberOrange.colour80 }}
{{- else if eq $colour "ash-beige" }}
{{- $faviconFolder = "ashBeige"}}
{{- $faviconColour = .Site.Data.themeColoursAshBeige.colour50 }}
{{- $themeColour = .Site.Data.themeColoursAshBeige.colour80 }}
{{- else if eq $colour "lavender-blue" }}
{{- $faviconFolder = "lavenderBlue"}}
{{- $faviconColour = .Site.Data.themeColoursLavenderBlue.colour50 }}
{{- $themeColour = .Site.Data.themeColoursLavenderBlue.colour80 }}
{{- else if eq $colour "lilac-pink" }}
{{- $faviconFolder = "lilacPink"}}
{{- $faviconColour = .Site.Data.themeColoursLilacPink.colour50 }}
{{- $themeColour = .Site.Data.themeColoursLilacPink.colour80 }}
{{- else if eq $colour "lime-green" }}
{{- $faviconFolder = "limeGreen"}}
{{- $faviconColour = .Site.Data.themeColoursLimeGreen.colour50 }}
{{- $themeColour = .Site.Data.themeColoursLimeGreen.colour80 }}
{{- else if eq $colour "mustard-yellow" }}
{{- $faviconFolder = "mustardYellow"}}
{{- $faviconColour = .Site.Data.themeColoursMustardYellow.colour50 }}
{{- $themeColour = .Site.Data.themeColoursMustardYellow.colour80 }}
{{- else if eq $colour "olive-green" }}
{{- $faviconFolder = "oliveGreen"}}
{{- $faviconColour = .Site.Data.themeColoursOliveGreen.colour50 }}
{{- $themeColour = .Site.Data.themeColoursOliveGreen.colour80 }}
{{- else if eq $colour "plum-pink" }}
{{- $faviconFolder = "plumPink"}}
{{- $faviconColour = .Site.Data.themeColoursPlumPink.colour50 }}
{{- $themeColour = .Site.Data.themeColoursPlumPink.colour80 }}
{{- else if eq $colour "sea-blue" }}
{{- $faviconFolder = "seaBlue"}}
{{- $faviconColour = .Site.Data.themeColoursSeaBlue.colour50 }}
{{- $themeColour = .Site.Data.themeColoursSeaBlue.colour80 }}
{{- else if eq $colour "steel-grey" }}
{{- $faviconFolder = "steelGrey"}}
{{- $faviconColour = .Site.Data.themeColoursSteelGrey.colour50 }}
{{- $themeColour = .Site.Data.themeColoursSteelGrey.colour80 }}
{{- end }}
<meta name='theme-color' content='{{ $themeColour }}'>
{{- /* get the theme colour’s corresponding data file so we can use its values */ -}}
{{- $faviconIco := printf "/favicons/%v/favicon.ico" $faviconFolder -}}
{{- if (fileExists "static/favicon.ico") }}
<link rel='alternate icon' href='favicon.ico'>
{{- else }}
<link rel='alternate icon' href='{{ printf "%v" $faviconIco }}'>
{{- end }}
{{ $colourFile := index site.Data.colourThemes.themes $colourTheme }}
{{- $appleTouchIcon := printf "/favicons/%v/apple-touch-icon.png" $faviconFolder -}}
{{- if (fileExists "static/apple-touch-icon.png") }}
<link rel='apple-touch-icon' sizes='180x180' href='apple-touch-icon.png'>
{{- else }}
<link rel='apple-touch-icon' sizes='180x180' href='{{ printf "%v" $appleTouchIcon }}'>
{{- end }}
{{- /* get the theme colours’s theme lightmode colour from the colour file */ -}}
{{- $favicon32 := printf "/favicons/%v/favicon-32x32.png" $faviconFolder -}}
{{- if (fileExists "static/favicon-32x32.png") }}
<link rel='icon' type='image/png' sizes='32x32' href='favicon-32x32.png'>
{{- else }}
<link rel='icon' type='image/png' sizes='32x32' href='{{ printf "%v" $favicon32 }}'>
{{- end }}
{{ $themeLightmode := $colourFile.themeLightmode }}
{{- $favicon16 := printf "/favicons/%v/favicon-16x16.png" $faviconFolder -}}
{{- if (fileExists "static/favicon-16x16.png") }}
<link rel='icon' type='image/png' sizes='16x16' href='favicon-16x16.png'>
{{- else }}
<link rel='icon' type='image/png' sizes='16x16' href='{{ printf "%v" $favicon16 }}'>
{{- end }}
{{- /* get the theme colours’s theme darkmode colour from the colour file */ -}}
<meta name='msapplication-TileColor' content='{{ $faviconColour }}'>
{{- $browserConfigXML := resources.Get "favicons/browserconfig.xml" }}
{{- $browserConfigXMLFile := $browserConfigXML | resources.ExecuteAsTemplate "browserconfig.xml" . }}
{{ printf "<!-- Browser config file is at %s -->" $browserConfigXMLFile.RelPermalink | safeHTML }}
{{ $themeDarkmode := $colourFile.themeDarkmode }}
{{- $webmanifest := resources.Get "favicons/site.webmanifest" }}
{{- $webmanifestFile := $webmanifest | resources.ExecuteAsTemplate "site.webmanifest" . }}
<link rel='manifest' href='{{ $webmanifestFile.RelPermalink }}'>
{{- $faviconSvg := printf "/favicons/%v/favicon.svg" $faviconFolder -}}
{{- if (fileExists "static/favicon.svg") }}
<link rel='icon' type='image/svg+xml' href='/favicon.svg'>
{{- else }}
<link rel='icon' type='image/svg+xml' href='{{ printf "%v" $faviconSvg }}'>
{{- end }}
\ No newline at end of file
<meta name='theme-color' content='{{ $colourFile }}'>
<meta name="theme-color" media="(prefers-color-scheme: light)" content="{{ $themeLightmode }}">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="{{ $themeDarkmode }}">
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment