From 4bb4bb00b433227605a940c76e731db0f1a7577f Mon Sep 17 00:00:00 2001 From: John Letey Date: Wed, 27 Feb 2019 14:41:56 +0000 Subject: [PATCH] feat: add ability to add custom css and js --- exampleSite/config.toml | 5 +++++ layouts/partials/head.html | 8 +++++--- layouts/partials/javascript.html | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 1ff142c5a..14376ceff 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -62,6 +62,11 @@ disableHugoGeneratorInject = false # Prefix of link to the git commit detail page. GitInfo must be enabled. # gitUrl = "" + # Integrate Javascript files or stylesheets by adding the url to the external assets or by + # linking local files with their path relative to the static folder, e.g. "css/styles.css" + customCSS = [] + customJS = [] + # Toggle this option need to rebuild SCSS, requires extended version of Hugo justifyContent = false # Set "text-align: justify" to .content. diff --git a/layouts/partials/head.html b/layouts/partials/head.html index bcab31217..48b2ebdf8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -24,9 +24,11 @@ {{ $style := resources.Get "scss/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }} -{{- range .Site.Params.customCSS }} - -{{- end }} +{{ range $val := $.Site.Params.customCSS }} + {{ if gt (len $val) 0 }} + + {{ end }} +{{ end }} {{- partial "favicons.html" }} diff --git a/layouts/partials/javascript.html b/layouts/partials/javascript.html index e6b0fa054..6d0d7e54a 100644 --- a/layouts/partials/javascript.html +++ b/layouts/partials/javascript.html @@ -16,3 +16,9 @@ ga('send', 'pageview'); {{- end}} + +{{ range $val := $.Site.Params.customJS }} + {{ if gt (len $val) 0 }} + + {{ end }} +{{ end }}