enable reading template variable from JS files

This commit is contained in:
mivinci 2021-08-23 21:40:38 +08:00
parent e7eb6932e2
commit e90b28cd24
4 changed files with 9 additions and 5 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
.DS_Store
public
public
resources

View file

@ -1,4 +1,5 @@
const light = '🌝', dark = '🌚';
const light = '{{ index .Site.Params.switch 1 }}',
dark = '{{ index .Site.Params.switch 0 }}';
const LIGHT = 'light', DARK = 'dark';
const themeSwitcher = document.getElementById('theme-switcher');

View file

@ -13,7 +13,7 @@ disqusShortname = "hugo-minima"
[author]
name = "XJJ"
slogon = "A student and web developer from Earth 🌍"
description = "This is Minima, a clean and minimal Hugo theme porting from Minima on Hexo. It not only inherits everything from Hexo Minima like dark/light mode but intgrated KaTeX and some taxonomies like categories, series and tags. I created this from scratch using pure CSS and Vanilla JS without using unnecessary development packs! 😁"
description = "This is Minima, a clean and minimal Hugo theme porting from Minima on Hexo. It not only inherits everything from Hexo Minima like dark/light mode but intgrated KaTeX and some taxonomies like categories, series and tags. I created this from scratch using SCSS and Vanilla JS without unnecessary development packs! 😁"
[params]
@ -27,6 +27,8 @@ subtitle = ""
comment = "disqus"
# timeformat
timeformat = "Jan 2, 2006"
# switch for turning on/off lights.
switch = ["🌚", "🌝"]
# OvO is a comment plugin written by the author of Minima.

View file

@ -24,8 +24,8 @@
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS $options }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{ $options := (dict "targetPath" (printf `minima.%d.js` $hash) "minify" true) }}
{{ $js := resources.Get "js/main.js" | js.Build $options }}
{{ $options = (dict "targetPath" (printf `minima.%d.js` $hash) "minify" true) }}
{{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate (printf `minima.%d.js` $hash) . }}
<script defer type="text/javascript" src="{{ $js.RelPermalink }}"></script>
</head>
<script>