Просмотр исходного кода

refactor: lint JS

Follows on from d18b2c9defc6e52050fb2f2defffeab315a9f472
George Cushen 4 лет назад
Родитель
Сommit
a4bc42feb6
3 измененных файлов с 13 добавлено и 4 удалено
  1. 11 0
      .github/contributing.md
  2. 1 3
      wowchemy/assets/js/wowchemy.js
  3. 1 1
      wowchemy/layouts/partials/site_js.html

+ 11 - 0
.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)

+ 1 - 3
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}`);
 
 /* ---------------------------------------------------------------------------

+ 1 - 1
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 }}