From 90eb10ea7a7299132529fcb11e31d957206f36b5 Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Tue, 12 May 2020 20:22:51 +0200 Subject: [PATCH] babel pipe to hugo extended test --- .gitignore | 2 ++ babel.config.js | 11 ++++++++ package.json | 28 +++++++++++++++++++ .../assets/js/redzuurdesem.js | 4 +-- .../layouts/partials/footer.html | 7 ++++- 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 babel.config.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index ce95628..8b69e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +package-lock.json docs/ @@ -6,6 +7,7 @@ docs/ **/*.sublime-workspace resources/_gen/ +node_modules/ content/boek/src/boek.tex content/boek/src/boek.pdf diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..3a24ed3 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,11 @@ +module.exports = function (api) { + api.cache(true); + + const presets = [ '@babel/preset-env' ]; + const plugins = [ ]; + + return { + presets, + plugins + }; +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..efc311d --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "redzuurdesem", + "version": "1.0.0", + "description": "", + "main": "babel.config.js", + "directories": { + "doc": "docs" + }, + "dependencies": {}, + "devDependencies": { + "@babel/cli": "^7.8.4", + "@babel/core": "^7.9.6", + "@babel/preset-env": "^7.9.6" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wgroeneveld/redzuurdesem.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/wgroeneveld/redzuurdesem/issues" + }, + "homepage": "https://github.com/wgroeneveld/redzuurdesem#readme" +} diff --git a/themes/desem-swift-theme/assets/js/redzuurdesem.js b/themes/desem-swift-theme/assets/js/redzuurdesem.js index 417a882..f44f374 100644 --- a/themes/desem-swift-theme/assets/js/redzuurdesem.js +++ b/themes/desem-swift-theme/assets/js/redzuurdesem.js @@ -2,7 +2,7 @@ function modifyClass(el, targetClass) { if (isObj(el) && targetClass) { - elClass = el.classList; + const elClass = el.classList; elClass.contains(targetClass) ? elClass.remove(targetClass) : elClass.add(targetClass); } } @@ -29,7 +29,7 @@ function pushClass(el, targetClass) { if (isObj(el) && targetClass) { - elClass = el.classList; + const elClass = el.classList; elClass.contains(targetClass) ? false : elClass.add(targetClass); } } diff --git a/themes/desem-swift-theme/layouts/partials/footer.html b/themes/desem-swift-theme/layouts/partials/footer.html index 2b8a39e..1df29fc 100644 --- a/themes/desem-swift-theme/layouts/partials/footer.html +++ b/themes/desem-swift-theme/layouts/partials/footer.html @@ -7,7 +7,12 @@ {{- $mainScriptPath := "js/redzuurdesem.js" }} -{{- $scripts := resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . | resources.Minify | resources.Fingerprint "sha512" }} +{{- $scripts := "" }} +{{- if (ne hugo.Environment "development") }} + {{- $scripts = resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . | babel | resources.Minify | resources.Fingerprint "sha512" }} +{{- else }} + {{- $scripts = resources.Get $mainScriptPath | resources.ExecuteAsTemplate $mainScriptPath . }} +{{- end }}