diff --git a/README.md b/README.md index 9c100f9..af037de 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ after `1.9.0` were actually the same as `1.9.0` because the build step was not e I then made the following changes: - add [dev container](https://code.visualstudio.com/docs/devcontainers/containers) configuration - exact search using quotes instead of trailing space -- add query parameter to middleware +- add `query` and `match` parameters to middleware - split search criteria on words instead of space - add package version to header @@ -189,7 +189,7 @@ Example: ```js SimpleJekyllSearch({ ... - templateMiddleware: function(prop, value, template, query) { + templateMiddleware: function(prop, value, template, query, match) { if (prop === 'bar') { return value.replace(/^\//, '') } diff --git a/WIKI.md b/WIKI.md index 7196e31..e572800 100644 --- a/WIKI.md +++ b/WIKI.md @@ -68,7 +68,7 @@ Example: ```js SimpleJekyllSearch({ ... - templateMiddleware: function(prop, value, template, query) { + templateMiddleware: function(prop, value, template, query, match) { if (prop === 'bar') { return value.replace(/^\//, '') } diff --git a/example/Gemfile.lock b/example/Gemfile.lock new file mode 100644 index 0000000..561b9f5 --- /dev/null +++ b/example/Gemfile.lock @@ -0,0 +1,69 @@ +GEM + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + colorator (1.1.0) + concurrent-ruby (1.3.4) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + ffi (1.17.0-x86_64-linux-gnu) + forwardable-extended (2.6.0) + google-protobuf (3.25.5-x86_64-linux) + http_parser.rb (0.8.0) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + jekyll (4.3.4) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (>= 0.3.6, < 0.5) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) + jekyll-watch (2.2.1) + listen (~> 3.0) + kramdown (2.5.1) + rexml (>= 3.3.9) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.4.0) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (6.0.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rexml (3.3.9) + rouge (4.5.1) + safe_yaml (1.0.5) + sass-embedded (1.62.1-x86_64-linux-gnu) + google-protobuf (~> 3.21) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.6.0) + webrick (1.9.1) + +PLATFORMS + x86_64-linux-gnu + +DEPENDENCIES + jekyll + +BUNDLED WITH + 2.5.23 diff --git a/package.json b/package.json index 0610c67..5c4ceea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-jekyll-search", - "version": "1.13.0", + "version": "1.14.0", "description": "Simple Jekyll site search using javascript and json", "main": "dest/simple-jekyll-search.js", "scripts": { diff --git a/scripts/stamp.js b/scripts/stamp.js index 88f23db..81b9e88 100644 --- a/scripts/stamp.js +++ b/scripts/stamp.js @@ -11,7 +11,7 @@ const year = new Date().getFullYear() const stampTop = `/*! * Simple-Jekyll-Search ${version} - * Copyright 2015-${year}, Christian Fei + * Copyright 2015-${year}, Christian Fei, Neil Boyd * Licensed under the MIT License. */ diff --git a/tests/Templater.test.js b/tests/Templater.test.js index d8d4ec1..ad79a2e 100644 --- a/tests/Templater.test.js +++ b/tests/Templater.test.js @@ -30,6 +30,16 @@ test('renders the template with the provided data and query', t => { t.deepEqual(templater.compile({ url: 'http://google.com', query: 'bar' }), 'url') }) +test('renders the template with the match', t => { + t.deepEqual(templater.compile({ foo: 'bar' }), 'bar') + + templater.setOptions({ + template: '{match}' + }) + + t.deepEqual(templater.compile({ match: 'bar' }), 'bar') +}) + test('replaces not found properties with the original pattern', t => { const template = '{foo}' templater.setOptions({