From a4bc42feb64715ff760a585a931e72782df680b7 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 9 Jan 2021 19:53:11 +0000 Subject: [PATCH] refactor: lint JS Follows on from d18b2c9defc6e52050fb2f2defffeab315a9f472 --- .github/contributing.md | 11 +++++++++++ wowchemy/assets/js/wowchemy.js | 4 +--- wowchemy/layouts/partials/site_js.html | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/contributing.md b/.github/contributing.md index 183c4af1..3ff59b51 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -20,6 +20,17 @@ If you have a straightforward bug fix or improvement, feel free to contribute it If you have an idea for a new feature, please start by [searching the issues](https://github.com/wowchemy/wowchemy-hugo-modules/issues) to check that the feature has not already been suggested and then suggest it by [opening a new issue](https://github.com/wowchemy/wowchemy-hugo-modules/issues/new/choose), as adding new features to Wowchemy first requires some analysis around the design and spec. +Code linting and formatting form part of the Continuous Integration process to help catch bugs and code issues in contributions. + +Contributors can also run the flow on their fork of the "Wowchemy Hugo Modules" repo when making contributions (you'll need Node and Yarn to run): +```sh +cd wowchemy +yarn install +yarn run lint:js +yarn run lint:style +yarn run format +``` + ### Contribute a widget [Create and publish your own widget](https://github.com/wowchemy/wowchemy-widget-starter) diff --git a/wowchemy/assets/js/wowchemy.js b/wowchemy/assets/js/wowchemy.js index bc1fa27e..a169df18 100644 --- a/wowchemy/assets/js/wowchemy.js +++ b/wowchemy/assets/js/wowchemy.js @@ -5,7 +5,7 @@ * Core JS functions and initialization. **************************************************/ -import {hugoEnvironment, codeHighlighting} from '@params'; +import {hugoEnvironment, codeHighlighting, searchEnabled} from '@params'; import {fixMermaid} from './wowchemy-utils'; @@ -16,8 +16,6 @@ import { onMediaQueryListEvent, } from './wowchemy-theming'; -const searchEnabled = typeof search_config !== 'undefined'; - console.debug(`Environment: ${hugoEnvironment}`); /* --------------------------------------------------------------------------- diff --git a/wowchemy/layouts/partials/site_js.html b/wowchemy/layouts/partials/site_js.html index 7af4f1f2..964f1f6a 100644 --- a/wowchemy/layouts/partials/site_js.html +++ b/wowchemy/layouts/partials/site_js.html @@ -136,7 +136,7 @@ {{ $js_license := $js_license | printf "%s/*! License: https://github.com/wowchemy/wowchemy-hugo-modules/blob/master/LICENSE.md */\n" }} {{ $js_bundle_head := $js_license | resources.FromString "js/bundle-head.js" }} {{ $js_linebreak := "\n" | resources.FromString "js/linebreak.js" }}{{/* Fix no line break after Bootstrap JS causing error. */}} - {{ $js_params := dict "hugoEnvironment" hugo.Environment "codeHighlighting" ($scr.Get "highlight_enabled" | default false) }} + {{ $js_params := dict "hugoEnvironment" hugo.Environment "codeHighlighting" ($scr.Get "highlight_enabled" | default false) "searchEnabled" (ne site.Params.search.engine 0) }} {{ $js_academic := resources.Get "js/wowchemy.js" | js.Build (dict "params" $js_params) }} {{ $js_bootstrap := resources.Get "js/_vendor/bootstrap.bundle.js" }} {{ $js_bundle := slice $js_bootstrap $js_linebreak $js_academic }}