Commit bcea6e06 authored by Lars Kruse's avatar Lars Kruse

Add support for page-specific extra scripts

The new front matter variable `page_scripts` allows to specify
javascript ressources to be loaded in sync or async mode.
This allows javascript code to be loaded, that is only required for a
small set of pages (e.g. showing a map or a slider animation).

(cherry picked from commit 08df330971dc8c2c738069401356b22f568c17e5)
parent cd355e60
......@@ -146,6 +146,23 @@ If you add a key of `show_reading_time` true to either the Config Params, a page
Some scripts need to be added within the page head. To add your own scripts to the page head, simply insert them into the `head-additions.html` partial located in the `layouts/partials` folder.
### Adding Scripts to Specific Pages
Some pages may require extra scripts (e.g. for showing a map or a slider animation).
These can be specified by setting the `page_scripts` value in the front matter.
Its keys `sync` and `async` may contain lists of script locations.
title: foo
- /js/foo.js
- /js/bar.js
- /js/baz.js
### Logo
You can replace the title of your site in the top left corner of each page with your own logo. To do that put your own logo into the `static` directory of your website, and add the `site_logo` parameter to the site params in your config file. For example:
......@@ -52,6 +52,6 @@
{{ block "main" . }}{{ end }}
{{ block "footer" . }}{{ partialCached "site-footer.html" . }}{{ end }}
{{ block "scripts" . }}{{ partialCached "site-scripts.html" . }}{{ end }}
{{ block "scripts" . }}{{ partialCached "site-scripts.html" . (default "" .Params.page_scripts) }}{{ end }}
......@@ -2,3 +2,9 @@
{{ with $script.js }}
<script src="{{ relURL (printf "%s%s" "dist/" .) }}"></script>
{{ end }}
{{ range .Params.page_scripts.sync }}
<script src="{{ relURL (.) }}"></script>
{{ end }}
{{ range .Params.page_scripts.async }}
<script async src="{{ relURL (.) }}"></script>
{{ end }}
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