support custom css and js files
This commit is contained in:
parent
da0a871758
commit
9824fe3e2e
10
README.md
10
README.md
|
@ -18,7 +18,7 @@ An accessibility-friendly Hugo theme, ported from the [original Cupper](https://
|
||||||
- [Syntax highlighting](#syntax-highlighting)
|
- [Syntax highlighting](#syntax-highlighting)
|
||||||
- [Disable toc for a blog post](#disable-toc-for-a-blog-post)
|
- [Disable toc for a blog post](#disable-toc-for-a-blog-post)
|
||||||
- [Localization](#localization)
|
- [Localization](#localization)
|
||||||
- [Custom css](#custom-css)
|
- [Custom CSS and JS](#custom-css-and-js)
|
||||||
- [Getting help](#getting-help)
|
- [Getting help](#getting-help)
|
||||||
- [Credits](#credits)
|
- [Credits](#credits)
|
||||||
|
|
||||||
|
@ -92,11 +92,13 @@ The strings in the templates of this theme can be localized. Make a copy of `<TH
|
||||||
|
|
||||||
[Here is a tutorial that goes more in depth about this.](https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-2-i18n-string-localization/)
|
[Here is a tutorial that goes more in depth about this.](https://regisphilibert.com/blog/2018/08/hugo-multilingual-part-2-i18n-string-localization/)
|
||||||
|
|
||||||
## Custom css
|
## Custom CSS and JS
|
||||||
|
|
||||||
Instead of copying the theme's css file to your own installation and modifying this large file, you can provide a list of css files that will be loaded after the theme's one. This enables you to override individual style while getting theme updates when they come.
|
You can provide an optional list of custom CSS files, which must be placed inside the `static` dir. These will load after the theme CSS loads. So, `static/css/custom_01.css` translates to `css/custom_01.css`.
|
||||||
|
|
||||||
Please see the params section of the example site `config.yaml` for more details.
|
You can provide an optional list of custom JS files, which must be placed inside the `static` dir. These will load after the theme JS loads. So, `static/js/custom_01.js` translates to `js/custom_01.js`.
|
||||||
|
|
||||||
|
See the [example site config file](https://github.com/zwbetz-gh/cupper-hugo-theme/blob/master/exampleSite/config.yaml) for sample usage.
|
||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
|
|
|
@ -27,14 +27,12 @@ params:
|
||||||
darkThemeAsDefault: false
|
darkThemeAsDefault: false
|
||||||
hideHeaderLinks: false
|
hideHeaderLinks: false
|
||||||
search: true
|
search: true
|
||||||
# A list of custom css files can be provided, which must be placed inside
|
customCss:
|
||||||
# 'static/'.
|
- css/custom_01.css
|
||||||
# This is useful to override just specific css classes, instead of copying
|
- css/custom_02.css
|
||||||
# the entire theme's css file to your own site.
|
customJs:
|
||||||
# Usage:
|
- js/custom_01.js
|
||||||
# customCss:
|
- js/custom_02.js
|
||||||
# - css/foo.css # relative path starting from static/
|
|
||||||
#- css/bar.css
|
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
nav:
|
nav:
|
||||||
|
|
3
exampleSite/static/css/custom_01.css
Normal file
3
exampleSite/static/css/custom_01.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.your-custom-class-01 {
|
||||||
|
display: block;
|
||||||
|
}
|
3
exampleSite/static/css/custom_02.css
Normal file
3
exampleSite/static/css/custom_02.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.your-custom-class-02 {
|
||||||
|
display: block;
|
||||||
|
}
|
3
exampleSite/static/js/custom_01.js
Normal file
3
exampleSite/static/js/custom_01.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
const yourCustomFunction01 = (message) => {
|
||||||
|
console.log(message);
|
||||||
|
};
|
3
exampleSite/static/js/custom_02.js
Normal file
3
exampleSite/static/js/custom_02.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
const yourCustomFunction02 = (message) => {
|
||||||
|
console.log(message);
|
||||||
|
};
|
|
@ -26,9 +26,9 @@
|
||||||
{{ $styles := $templateStyles | resources.ExecuteAsTemplate "css/styles.css" . }}
|
{{ $styles := $templateStyles | resources.ExecuteAsTemplate "css/styles.css" . }}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ $styles.Permalink }}">
|
<link rel="stylesheet" type="text/css" href="{{ $styles.Permalink }}">
|
||||||
|
|
||||||
{{ range .Site.Params.customCss -}}
|
{{ range .Site.Params.customCss }}
|
||||||
<link rel="stylesheet" href="{{ . | absURL }}">
|
<link rel="stylesheet" href="{{ . | absURL }}">
|
||||||
{{- end }}
|
{{ end }}
|
||||||
|
|
||||||
<style id="inverter" media="none">
|
<style id="inverter" media="none">
|
||||||
.intro-and-nav, .main-and-footer { filter: invert(100%) }
|
.intro-and-nav, .main-and-footer { filter: invert(100%) }
|
||||||
|
|
|
@ -10,3 +10,7 @@
|
||||||
{{ $searchCss := resources.Get "css/search.css" | fingerprint }}
|
{{ $searchCss := resources.Get "css/search.css" | fingerprint }}
|
||||||
<link rel="stylesheet" href="{{ $searchCss.RelPermalink }}"></link>
|
<link rel="stylesheet" href="{{ $searchCss.RelPermalink }}"></link>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range .Site.Params.customJs }}
|
||||||
|
<script src="{{ . | absURL }}"></script>
|
||||||
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user