⌨ Added abilitiy to include remote JavaScript files
Closes #39
| | |
| | | ``` |
| | | `hello.js` and `world.js` will be bundled into a `custom.min.js`. |
| | | |
| | | You can also include links to remote javascript files (hosted on CDNs for example). But be aware, that integrity settings and minification won't be applied. Further make sure to adjust your CSP. You can load a remote script like this: |
| | | ```toml |
| | | [params] |
| | | customJs = ["http://cdn.exmple.org/fancyscript.js"] |
| | | ``` |
| | | Both approaches can even be mixed: |
| | | ```toml |
| | | [params] |
| | | customJs = ["https://cdn.exmple.org/fancyscript.js", "js/world.js"] |
| | | ``` |
| | | ### Content Security Policy |
| | | The theme is compliant with most strict CSP policies out of the box. A sample CSP for an Anatole-based site would look something like this: |
| | | |
| | |
| | | |
| | | {{- $js := "" -}} |
| | | {{- range .Site.Params.customJs -}} |
| | | {{- $customJS := resources.Get . -}} |
| | | {{- if $customJS -}} |
| | | {{- if eq $js "" -}} |
| | | {{- $js = $customJS -}} |
| | | {{- else -}} |
| | | {{- $js = slice $js $customJS | resources.Concat "js/custom.js" -}} |
| | | {{- if or (in . "http://") (in . "https://") -}} |
| | | <script src="{{ . | relURL }}"></script> |
| | | {{- else -}} |
| | | {{- $customJS := resources.Get . -}} |
| | | {{- if $customJS -}} |
| | | {{- if eq $js "" -}} |
| | | {{- $js = $customJS -}} |
| | | {{- else -}} |
| | | {{- $js = slice $js $customJS | resources.Concat "js/custom.js" -}} |
| | | {{- end -}} |
| | | {{- end -}} |
| | | {{- end -}} |
| | | {{- end -}} |