Allow the Page's resources front matter to control whether a JS script is imported as a module

resources:
  - src: script.js
    params:
      is_module: <true|false>
This commit is contained in:
Eryn Wells 2022-08-18 20:19:10 -07:00
parent 7b9cb6bf73
commit 55781cd599

View file

@ -57,7 +57,8 @@
{{ end }}
{{ range $script := .Resources.Match "*.js" }}
<script defer type="module" src="{{ $script.Permalink | relURL }}"></script>
{{ $isModule := default true $script.Params.is_module }}
<script defer {{ if $isModule }}type="module"{{ end }} src="{{ $script.Permalink | relURL }}"></script>
{{ end }}
<!-- Misc -->