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

github.com/jpescador/hugo-future-imperfect.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Pescador <jpescador@users.noreply.github.com>2016-04-12 23:46:30 +0300
committerJulio Pescador <jpescador@users.noreply.github.com>2016-04-12 23:46:30 +0300
commitaecd3169d510f234ffe059b8e2301998aaadd45a (patch)
tree8c9fafc501dd9f3848478d40ecab42f5435a5d59
parentd2a763d68c7554672edb17e58e66f462a805e991 (diff)
Adding new Site params, customCSS and customJSv0.3
The following site params, customCSS and customJS have been added. This replaces the deprecated params minifiedFilesCSS and minifiedFilesJS. The params remain as an array and the ability to load the standard theme files is available. Simply add the value, "default", into the array. This resolves the following issue: https://github.com/jpescador/hugo-future-imperfect/issues/3
-rw-r--r--exampleSite/config.toml17
-rw-r--r--layouts/partials/footer.html27
-rw-r--r--layouts/partials/header.html27
3 files changed, 53 insertions, 18 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 6daf43f..73a675d 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -26,12 +26,17 @@ googleAnalytics = ""
# Please see the favicon partial template for more information
loadFavicon = false
faviconVersion = ""
- # Load minified files instead of the non minified files. The variable
- # is an array so that you can load multiple min files if necessary
- # Note: There are other ways to approach minification
- # This is just an additional option if you wish to use this
- minifiedFilesCSS = ["/css/main.min.css"]
- minifiedFilesJS = ["/js/main.min.js"]
+
+ # Load custom CSS or JavaScript files. This replaces the deprecated params
+ # minifiedFilesCSS and minifiedFilesJS. The variable is an array so that you
+ # can load multiple files if necessary. You can also load the standard theme
+ # files by adding the value, "default".
+ # customCSS = ["default", "/path/to/file"]
+ # customJS = ["default", "/path/to/file"]
+
+ # Loading min files for exampleSite
+ customCSS = ["/css/main.min.css"]
+ customJS = ["/js/main.min.js"]
# parms.intro will appear on the sidebar
# This is optional, but it's suggested to use
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 22a6f59..9f9c889 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,15 +1,21 @@
</div>
<a id="back-to-top" href="#" class="fa fa-arrow-up fa-border fa-2x"></a>
<!-- Scripts -->
- {{ $minFiles := .Site.Params.minifiedFilesJS }}
+ <!-- Keeping the deprecated param, minifiedFilesJS, for now. The new param
+ that replaces this is customJS. Utilizing a scratch variable jsFiles
+ to keep the deprecated param. -->
{{ if isset .Site.Params "minifiedFilesJS" }}
- {{ if ge (len $minFiles) 1 }}
- {{ range .Site.Params.minifiedFilesJS }}
- <script src="{{ . }}"></script>
- {{ end }}
- {{ end }}
+ {{ $.Scratch.Set "jsFiles" .Site.Params.minifiedFilesJS }}
+ {{ else if isset .Site.Params "customJS" }}
+ {{ $.Scratch.Set "jsFiles" .Site.Params.customJS }}
{{ else }}
+ {{ $.Scratch.Set "jsFiles" false }}
+ {{ end }}
+
+ <!-- If the value "default" is passed into the param then we will first
+ load the standard js files associated with the theme -->
+ {{ if or (in ($.Scratch.Get "jsFiles") "default") (eq ($.Scratch.Get "jsFiles") false) }}
<script src="/js/jquery.min.js"></script>
<script src="/js/skel.min.js"></script>
<script src="/js/util.js"></script>
@@ -17,6 +23,15 @@
<script src="/js/backToTop.js"></script>
<script src="/js/highlight.pack.js"></script>
{{ end }}
+
+ {{ if ne ($.Scratch.Get "jsFiles") false }}
+ {{ range $.Scratch.Get "jsFiles" }}
+ {{ if ne . "default" }}
+ <script src="{{ . }}"></script>
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
<!-- This is called by default since this theme uses highlight.js -->
<script>hljs.initHighlightingOnLoad();</script>
<!--[if lte IE 8]><script src="/js/ie/respond.min.js"></script><![endif]-->
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 6615be9..1d8b1a3 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -38,21 +38,36 @@
{{ template "_internal/google_news.html" . }}
<!--[if lte IE 8]><script src="/js/ie/html5shiv.js"></script><![endif]-->
- {{ $minFiles := .Site.Params.minifiedFilesCSS }}
+ <!-- Keeping the deprecated param, minifiedFilesCSS, for now. The new param
+ that replaces this is customCSS. Utilizing a scratch variable cssFiles
+ to keep the deprecated param. -->
{{ if isset .Site.Params "minifiedFilesCSS" }}
- {{ if ge (len $minFiles) 1 }}
- {{ range .Site.Params.minifiedFilesCSS }}
- <link rel="stylesheet" href="{{ . }}" />
- {{ end }}
- {{ end }}
+ {{ $.Scratch.Set "cssFiles" .Site.Params.minifiedFilesCSS }}
+ {{ else if isset .Site.Params "customCSS" }}
+ {{ $.Scratch.Set "cssFiles" .Site.Params.customCSS }}
{{ else }}
+ {{ $.Scratch.Set "cssFiles" false }}
+ {{ end }}
+
+ <!-- If the value "default" is passed into the param then we will first
+ load the standard css files associated with the theme -->
+ {{ if or (in ($.Scratch.Get "cssFiles") "default") (eq ($.Scratch.Get "cssFiles") false) }}
<link rel="stylesheet" href="/css/google-font.css" />
<link rel="stylesheet" href="/css/font-awesome.min.css" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/css/add-on.css" />
<link rel="stylesheet" href="/css/monokai-sublime.css">
{{ end }}
+
+ {{ if ne ($.Scratch.Get "cssFiles") false }}
+ {{ range $.Scratch.Get "cssFiles" }}
+ {{ if ne . "default" }}
+ <link rel="stylesheet" href="{{ . }}" />
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
<!--[if lte IE 9]><link rel="stylesheet" href="/css/ie9.css" /><![endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="/css/ie8.css" /><![endif]-->
{{ if not (in (printf "%#v" .Site.BaseURL) "localhost") }}