Add customJS

This commit is contained in:
vimux 2019-08-30 15:25:10 -04:00
parent a892076620
commit 05cbb49e9c
No known key found for this signature in database
GPG key ID: 5A34FDC4EE832E34
2 changed files with 25 additions and 0 deletions

View file

@ -28,6 +28,7 @@
- [Configuration options](#configuration-options) - [Configuration options](#configuration-options)
- [Columns](#columns) - [Columns](#columns)
- [Custom CSS](#custom-css) - [Custom CSS](#custom-css)
- [Custom JS](#custom-js)
- [Post Meta](#post-meta) - [Post Meta](#post-meta)
- [Related Content](#related-content) - [Related Content](#related-content)
- [Share Buttons](#share-buttons) - [Share Buttons](#share-buttons)
@ -140,6 +141,7 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
dateFormat = "January 02, 2006" # Change the format of dates dateFormat = "January 02, 2006" # Change the format of dates
colorTheme = "" # dark-green, dark-blue, dark-red, dark-violet colorTheme = "" # dark-green, dark-blue, dark-red, dark-violet
customCSS = ["css/custom.css"] # Include custom CSS files customCSS = ["css/custom.css"] # Include custom CSS files
customJS = ["js/custom.js"] # Include custom JS files
mainMenuAlignment = "right" # Align main menu (desktop version) to the right side mainMenuAlignment = "right" # Align main menu (desktop version) to the right side
authorbox = true # Show authorbox at bottom of single pages if true authorbox = true # Show authorbox at bottom of single pages if true
toc = true # Enable Table of Contents for all site pages toc = true # Enable Table of Contents for all site pages
@ -265,6 +267,26 @@ your Hugo site:
All custom CSS files will be added in the `head` section of a `baseof.html` right after the built-in CSS file. All custom CSS files will be added in the `head` section of a `baseof.html` right after the built-in CSS file.
#### Custom JS
You can add custom JavaScript files by assigning an array of references in site config file (`config.toml` by default)
like following:
```toml
[Params]
customJS = ["js/custom.js"]
```
And of course, just like with custom CSS, you can reference as many JS files as you want. Their paths need to be
relative to the `static` folder of your Hugo site:
```toml
[Params]
customJS = ["js/custom.js", "js/another.js"]
```
All custom JS files will be added before closing body tag of a `baseof.html` file.
#### Post Meta #### Post Meta
You may activate post meta fields with `.Site.Params.post_meta` parameter. You may activate post meta fields with `.Site.Params.post_meta` parameter.

View file

@ -50,5 +50,8 @@
<script src="{{ "js/menu.js" | relURL }}"></script> <script src="{{ "js/menu.js" | relURL }}"></script>
{{- end }} {{- end }}
{{- partial "mathjax.html" . -}} {{- partial "mathjax.html" . -}}
{{- range .Site.Params.customJS }}
<script src="{{ . | relURL }}"></script>
{{- end }}
</body> </body>
</html> </html>