Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/cupper-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwbetz-gh <zwbetz@gmail.com>2020-11-17 05:32:11 +0300
committerzwbetz-gh <zwbetz@gmail.com>2020-11-17 05:32:11 +0300
commit9824fe3e2e0b54c7320df87effcfed1455989119 (patch)
tree1cfd859a73b102220fe1853c3aa60e5c060d0615
parentda0a871758a9ebd1152256a838d29a07220348dd (diff)
support custom css and js files
-rw-r--r--README.md10
-rw-r--r--exampleSite/config.yaml14
-rw-r--r--exampleSite/static/css/custom_01.css3
-rw-r--r--exampleSite/static/css/custom_02.css3
-rw-r--r--exampleSite/static/js/custom_01.js3
-rw-r--r--exampleSite/static/js/custom_02.js3
-rw-r--r--layouts/partials/head.html4
-rw-r--r--layouts/partials/script.html4
8 files changed, 30 insertions, 14 deletions
diff --git a/README.md b/README.md
index 3e6a74c..474b365 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ An accessibility-friendly Hugo theme, ported from the [original Cupper](https://
- [Syntax highlighting](#syntax-highlighting)
- [Disable toc for a blog post](#disable-toc-for-a-blog-post)
- [Localization](#localization)
-- [Custom css](#custom-css)
+- [Custom CSS and JS](#custom-css-and-js)
- [Getting help](#getting-help)
- [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/)
-## 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
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 287122d..8240586 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -27,14 +27,12 @@ params:
darkThemeAsDefault: false
hideHeaderLinks: false
search: true
- # A list of custom css files can be provided, which must be placed inside
- # 'static/'.
- # This is useful to override just specific css classes, instead of copying
- # the entire theme's css file to your own site.
- # Usage:
- # customCss:
- # - css/foo.css # relative path starting from static/
- #- css/bar.css
+ customCss:
+ - css/custom_01.css
+ - css/custom_02.css
+ customJs:
+ - js/custom_01.js
+ - js/custom_02.js
menu:
nav:
diff --git a/exampleSite/static/css/custom_01.css b/exampleSite/static/css/custom_01.css
new file mode 100644
index 0000000..d4f4d54
--- /dev/null
+++ b/exampleSite/static/css/custom_01.css
@@ -0,0 +1,3 @@
+.your-custom-class-01 {
+ display: block;
+}
diff --git a/exampleSite/static/css/custom_02.css b/exampleSite/static/css/custom_02.css
new file mode 100644
index 0000000..d8bc55f
--- /dev/null
+++ b/exampleSite/static/css/custom_02.css
@@ -0,0 +1,3 @@
+.your-custom-class-02 {
+ display: block;
+}
diff --git a/exampleSite/static/js/custom_01.js b/exampleSite/static/js/custom_01.js
new file mode 100644
index 0000000..1bd9938
--- /dev/null
+++ b/exampleSite/static/js/custom_01.js
@@ -0,0 +1,3 @@
+const yourCustomFunction01 = (message) => {
+ console.log(message);
+};
diff --git a/exampleSite/static/js/custom_02.js b/exampleSite/static/js/custom_02.js
new file mode 100644
index 0000000..4fb8691
--- /dev/null
+++ b/exampleSite/static/js/custom_02.js
@@ -0,0 +1,3 @@
+const yourCustomFunction02 = (message) => {
+ console.log(message);
+};
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 2f20857..490f21d 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -26,9 +26,9 @@
{{ $styles := $templateStyles | resources.ExecuteAsTemplate "css/styles.css" . }}
<link rel="stylesheet" type="text/css" href="{{ $styles.Permalink }}">
- {{ range .Site.Params.customCss -}}
+ {{ range .Site.Params.customCss }}
<link rel="stylesheet" href="{{ . | absURL }}">
- {{- end }}
+ {{ end }}
<style id="inverter" media="none">
.intro-and-nav, .main-and-footer { filter: invert(100%) }
diff --git a/layouts/partials/script.html b/layouts/partials/script.html
index 793a553..2946b25 100644
--- a/layouts/partials/script.html
+++ b/layouts/partials/script.html
@@ -10,3 +10,7 @@
{{ $searchCss := resources.Get "css/search.css" | fingerprint }}
<link rel="stylesheet" href="{{ $searchCss.RelPermalink }}"></link>
{{ end }}
+
+{{ range .Site.Params.customJs }}
+ <script src="{{ . | absURL }}"></script>
+{{ end }}