bridgetown-quick-search 1.1.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25458440262a79aa91b1f6961ed7df41eef00a4350584a4e0441218715270610
4
- data.tar.gz: 030e1497c975cf0da2c72c20965ab21b53f13793cfa4eb163bc1c38ea9d9cc63
3
+ metadata.gz: 82f0598d813d41f5adf998da7b1215d26fba0f38a7e7a8cd2dc652585d61c561
4
+ data.tar.gz: 19cf61b695cf9b70db82ad90779b7471f3320bdd5b2f3c6c7b1df73f9b876c8e
5
5
  SHA512:
6
- metadata.gz: a6ae2ec88462c4309cbf0276a616f4df67625ed72196d2152f192dbe58c411cf6d358aeaea9c66ae65f5540a689cfbe230d53f7981fd93a11c025a532ae8ce47
7
- data.tar.gz: 7528416231c12f8efb183e1d26f182c4146f5a3363022f473c227d647fb20a7b5ce9f04ff94bfbebb24378cac46fc887d6c4201dad16fd356126de9fa6937122
6
+ metadata.gz: b98df2b8a247dfad28afca8c73b2ca596754552c0fa27754cc8a791a1fae428a99877d546785ea9299e5508f32f593f5eaf33d80e4cd6a1ce7042f78c3f72039
7
+ data.tar.gz: e5b0940fff821ef9c5b7f52b93d8fdb515ae28fff609cbd2223a4f038b64fcc5914680d01397a53d24fcc2037cd0d90bc79611a66a6ba2fccce2b26832d86903
data/.rubocop.yml CHANGED
@@ -4,19 +4,20 @@ inherit_gem:
4
4
  rubocop-bridgetown: .rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.5
8
- Include:
9
- - lib/**/*.rb
7
+ TargetRubyVersion: 3.1
10
8
 
11
9
  Exclude:
10
+ - Rakefile
12
11
  - .gitignore
13
12
  - .rspec
14
13
  - .rubocop.yml
15
14
 
16
15
  - Gemfile.lock
16
+ - "*.gemspec"
17
17
  - CHANGELOG.md
18
18
  - LICENSE.txt
19
19
  - README.md
20
20
 
21
21
  - script/**/*
22
22
  - vendor/**/*
23
+ - spec/**/*
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.0 / 2024-07-30
4
+
5
+ * Add collection name to preview title [#26] @thimy
6
+ * Add quick_search_content front matter overrides [#21] @copiousfreetime
7
+ * Add support for Bridgetown 2.0
8
+ * Switch to much improved esbuild build system for the repo
9
+
10
+ ## 2.0.0 / 2022-10-08
11
+
12
+ * Upgrade to new initializer system for Bridgetown 1.2
13
+
3
14
  ## 1.1.2 / 2021-10-11
4
15
 
5
16
  * Upgrade to newer Lit
data/README.md CHANGED
@@ -1,34 +1,29 @@
1
1
  # Bridgetown Quick Search plugin
2
2
 
3
- _Requires Bridgetown v0.15 or greater_
4
-
5
3
  This [Bridgetown](https://www.bridgetownrb.com) plugin provides a component you can add to your site (likely the top navbar) to allow fast, real-time search of your posts, pages, and other collection documents. It automatically generates a JSON index file which gets built along with the rest of the site, and then the component consumes that file and uses [Lunr.js](https://lunrjs.com) to construct the live search index and provide the search results as you type.
6
4
 
7
5
  ----
8
6
 
9
- ## Installation
7
+ ## Installation for Bridgetown 1.2+
10
8
 
11
9
  Run this command to add this plugin to your site's Gemfile:
12
10
 
13
11
  ```shell
14
- $ bundle add bridgetown-quick-search -g bridgetown_plugins
12
+ $ bundle add bridgetown-quick-search
15
13
  ```
16
14
 
17
- Next, add this line to the top of your frontend's Javascript index file:
18
-
19
- ```js
20
- // frontend/javascript/index.js
15
+ And then add the initializer to your configuration in `config/initializers.rb`:
21
16
 
22
- import "bridgetown-quick-search"
17
+ ```ruby
18
+ init :"bridgetown-quick-search"
23
19
  ```
24
20
 
25
- Or if you need a precompiled version (without experimental decorators), you can instead
26
- add the following:
21
+ Next, add this line to the top of your frontend's Javascript index file:
27
22
 
28
23
  ```js
29
24
  // frontend/javascript/index.js
30
25
 
31
- import "bridgetown-quick-search/dist"
26
+ import "bridgetown-quick-search"
32
27
  ```
33
28
 
34
29
  Then add the Liquid component to one of your site templates, for example `src/_components/navbar.liquid`:
@@ -51,11 +46,12 @@ You can provide additional Liquid variables to the component to configure its ap
51
46
  * `input_class`: Add custom CSS class names to the input control
52
47
  * `theme`: The component's default theme is a "light" appearance, but you can also set it to use a "dark" appearance
53
48
  * `snippet_length`: The length of the text snippet for each search result. Defaults to 142.
49
+ * `display_collection`: Will show collections to which belong search results if true. Defaults to false.
54
50
 
55
51
  Here's an example of using all variables at once:
56
52
 
57
53
  ```html
58
- {% render "bridgetown_quick_search/search", placeholder: "Search", input_class: "input", theme: "dark", snippet_length: 200 %}
54
+ {% render "bridgetown_quick_search/search", placeholder: "Search", input_class: "input", theme: "dark", snippet_length: 200, display_collection: true %}
59
55
  ```
60
56
 
61
57
  ## Styling
@@ -88,7 +84,10 @@ bridgetown-search-results::part(inner-link) {
88
84
 
89
85
  ## Controlling the Search Index
90
86
 
91
- You can add `exclude_from_search: true` to the front matter of any page or document to exclude it from the search index JSON. To batch-exclude pages, collections, categories, etc., you could use front matter defaults to set the `exclude_from_search` variable.
87
+ You can provide additional front matter variables to any page or document to control the search index. These are:
88
+
89
+ * `exclude_from_search: true`: Setting this will exclude that item from the search index JSON. To batch-exclude pages, collections, categories, etc., you could use front matter defaults to set the `exclude_from_search` variable.
90
+ * `quick_search_content: "content for the index"`: Setting this will override the content in the search index JSON. Normally the content in the search index JSON is the content of the page. Setting this front matter variable explicilty sets the content in the search index JSON.
92
91
 
93
92
  ## Testing
94
93
 
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Bridgetown::QuickSearch::VERSION
8
8
  spec.author = "Bridgetown Team"
9
9
  spec.email = "maintainers@bridgetownrb.com"
10
- spec.summary = "A Liquid + Web Component for Bridgetown sites which performs search queries with Lunr.js."
10
+ spec.summary = "A component for Bridgetown sites which performs search queries with Lunr.js."
11
11
  spec.homepage = "https://github.com/bridgetownrb/bridgetown-quick-search"
12
12
  spec.license = "MIT"
13
13
 
@@ -16,13 +16,13 @@ Gem::Specification.new do |spec|
16
16
  spec.require_paths = ["lib"]
17
17
  spec.metadata = { "yarn-add" => "bridgetown-quick-search@#{Bridgetown::QuickSearch::VERSION}" }
18
18
 
19
- spec.required_ruby_version = ">= 2.5.0"
19
+ spec.required_ruby_version = ">= 3.1.0"
20
20
 
21
- spec.add_dependency "bridgetown", ">= 0.15.0.beta1", "< 2.0"
21
+ spec.add_dependency "bridgetown", ">= 1.2.0.beta2", "< 3.0"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "nokogiri", "~> 1.6"
25
- spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rake", "~> 13.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
- spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
27
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
28
28
  end
@@ -4,8 +4,9 @@ variables:
4
4
  placeholder?: [string, Placeholder text for the search input control.]
5
5
  theme: [string, Dark or Light theme ("dark" or "light"). Defaults to light.]
6
6
  snippet_length?: [integer, Length of the result text snippet. Defaults to 142.]
7
+ display_collection?: [boolean, Displays the collection name. Defaults to false.]
7
8
  {% endcomment %}
8
9
  <bridgetown-search-form>
9
10
  <input slot="input" type="search" class="{{ input_class }}" placeholder="{{ placeholder }}" />
10
- <bridgetown-search-results {% if snippet_length %}snippetlength="{{ snippet_length }}" {% endif %}theme="{% if theme %}{{ theme }}{% endif %}"></bridgetown-search-results>
11
+ <bridgetown-search-results {% if snippet_length %}snippetlength="{{ snippet_length }}" {% endif %}theme="{% if theme %}{{ theme }} {% endif %}"{% if display_collection %} displayCollection="{{ display_collection }}"{% endif %}></bridgetown-search-results>
11
12
  </bridgetown-search-form>
@@ -1,15 +1,17 @@
1
1
  ---
2
2
  template_engine: liquid
3
+ layout: none
4
+ exclude_from_search: true
3
5
  ---
4
6
  [
5
7
  {%- assign looped = false %}
6
- {%- assign documents = site.documents %}
7
- {%- if site.content_engine == "resource" %}{% assign documents = site.resources %}{% endif %}
8
+ {%- assign documents = site.resources %}
8
9
  {%- for document in documents %}
9
10
  {%- if document.title %}
10
11
  {%- unless document.exclude_from_search or document.id == "" %}
11
- {%- assign url = document.url %}
12
- {%- if site.content_engine == "resource" %}{% assign url = document.relative_url %}{% endif %}
12
+ {%- assign url = document.relative_url %}
13
+ {%- assign content = document.content %}
14
+ {%- if document.quick_search_content %}{% assign content = document.quick_search_content %}{% endif %}
13
15
  {%- if looped %},{% endif %}
14
16
  {
15
17
  "id": "{{ url | slugify }}",
@@ -23,7 +25,7 @@ template_engine: liquid
23
25
  "categories": {{ document.categories | join: ", " | jsonify }},
24
26
  "tags": {{ document.tags | join: ", " | jsonify }},
25
27
  "url": {{ url | jsonify }},
26
- "content": {{ document.content | strip_html | replace_regex: "[\s/\n]+"," " | strip | jsonify }}
28
+ "content": {{ content | strip_html | replace_regex: "[\s/\n]+"," " | strip | jsonify }}
27
29
  }
28
30
  {%- assign looped = true %}
29
31
  {%- endunless %}
@@ -34,13 +36,15 @@ template_engine: liquid
34
36
  {%- if document.title %}
35
37
  {%- unless document.exclude_from_search %}
36
38
  {%- if looped %},{% endif %}
39
+ {%- assign content = document.content %}
40
+ {%- if document.quick_search_content %}{% assign content = document.quick_search_content %}{% endif %}
37
41
  {
38
42
  "id": "{{ document.url | slugify }}",
39
43
  "title": {{ document.title | jsonify }},
40
44
  "categories": {{ document.categories | join: ", " | jsonify }},
41
45
  "tags": {{ document.tags | join: ", " | jsonify }},
42
46
  "url": {{ document.url | jsonify }},
43
- "content": {{ document.content | strip_html | replace_regex: "[\s/\n]+"," " | strip | jsonify }}
47
+ "content": {{ content | strip_html | replace_regex: "[\s/\n]+"," " | strip | jsonify }}
44
48
  }
45
49
  {%- endunless %}
46
50
  {%- endif %}
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bridgetown
4
4
  module QuickSearch
5
- VERSION = "1.1.3"
5
+ VERSION = "3.0.0"
6
6
  end
7
7
  end
@@ -3,8 +3,10 @@
3
3
  require "bridgetown"
4
4
  require "bridgetown-quick-search/version"
5
5
 
6
- Bridgetown::PluginManager.new_source_manifest(
7
- origin: Bridgetown::QuickSearch,
8
- components: File.expand_path("../components", __dir__),
9
- content: File.expand_path("../content", __dir__)
10
- )
6
+ Bridgetown.initializer :"bridgetown-quick-search" do |config|
7
+ config.source_manifest(
8
+ origin: Bridgetown::QuickSearch,
9
+ components: File.expand_path("../components", __dir__),
10
+ content: File.expand_path("../content", __dir__)
11
+ )
12
+ end
data/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "bridgetown-quick-search",
3
- "version": "1.1.3",
4
- "main": "frontend/javascript/index.js",
5
- "module": "frontend/javascript/index.js",
3
+ "version": "3.0.0",
4
+ "main": "frontend/dist/index.js",
6
5
  "exports": {
7
- ".": "./frontend/javascript/index.js",
6
+ ".": "./frontend/dist/index.js",
7
+ "./javascript": {
8
+ "browser": "./frontend/javascript/index.js",
9
+ "import": "./frontend/javascript/index.js"
10
+ },
8
11
  "./dist": {
9
12
  "browser": "./frontend/dist/index.js",
10
13
  "import": "./frontend/dist/index.js"
@@ -22,17 +25,13 @@
22
25
  "frontend"
23
26
  ],
24
27
  "scripts": {
25
- "build": "babel ./frontend/javascript --out-dir ./frontend/dist"
28
+ "build": "esbuild frontend/javascript/index.js --bundle --outdir=frontend/dist --format=esm"
26
29
  },
27
30
  "dependencies": {
28
- "@babel/runtime": "^7.10.1",
29
- "lit": "^2.0.0",
31
+ "lit": "^3.1.0",
30
32
  "lunr": "^2.3.8"
31
33
  },
32
34
  "devDependencies": {
33
- "@babel/cli": "^7.12.1",
34
- "@babel/core": "^7.12.3",
35
- "@babel/plugin-proposal-class-properties": "^7.12.1",
36
- "@babel/plugin-proposal-decorators": "^7.12.1"
35
+ "esbuild": "^0.23.0"
37
36
  }
38
37
  }