From a5e95a82037fef350b0178b689ccd7972ee7208e Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Sun, 06 Dec 2020 16:31:54 +0000
Subject: [PATCH] add a js variables definition file

---
 layouts/partials/scripts.html |    5 ++++-
 assets/js/variables.js        |   14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/assets/js/variables.js b/assets/js/variables.js
new file mode 100644
index 0000000..ceaa52e
--- /dev/null
+++ b/assets/js/variables.js
@@ -0,0 +1,14 @@
+// global variables;
+const doc = document.documentElement;
+const toggleId = 'toggle';
+const showId = 'show';
+const menu = 'menu';
+
+// defined in config.toml
+const parentURL = '{{ absURL "" }}';
+
+// defined in i18n / translation files
+const quickLinks = '{{ T "quick_links" }}';
+const searchResultsLabel = '{{ T "search_results_label" }}';
+const typeToSearch = '{{ T "type_to_search" }}';
+const noMatchesFound = '{{ T "no_matches" }}';
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 7227c20..9cf3787 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -1,3 +1,6 @@
+{{- $variablesPath := "js/variables.js" }}
+{{- $variables := resources.Get $variablesPath | resources.ExecuteAsTemplate $variablesPath . }}
+
 {{- $funcPath := "js/functions.js" }}
 {{- $functions := resources.Get $funcPath | resources.ExecuteAsTemplate $funcPath . }}
 
@@ -10,7 +13,7 @@
 {{- $mainScriptPath := "js/index.js" }}
 {{- $main := resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . }}
 
-{{- $bundle := slice $functions $main | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
+{{- $bundle := slice $variables $functions $main | resources.Concat "js/bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
 {{- $bundle2 := slice $lunr $search | resources.Concat "js/search.js" | resources.Minify | resources.Fingerprint "sha512" }}
 <script src="{{ $bundle.Permalink }}"></script>
 <script src="{{ $bundle2.Permalink }}" async defer></script>

--
Gitblit v1.10.0