bridgetown-quick-search 2.0.0 → 3.0.1

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: edcd790fbcac2d5d75f5f175df2ce441842690553e4bc5af167948e5aaedc68f
4
- data.tar.gz: b31f224d49d765c284cdd0c69d86261696edadfe5ead4eee0b929776df3a5621
3
+ metadata.gz: e0a039c079736179c758b9a11eda4ebffaa86d6c3549a385491b0c62295ffc53
4
+ data.tar.gz: da0ebd8e750c30b6961a8e1d097d9cb0ebe1fb6c9f5e4994fed84f4772a9a687
5
5
  SHA512:
6
- metadata.gz: e2080d0597d679be8792a25b92145bf0f6c081717f1ec8870f56a75d399994d6fe119176e8fde45a23321359b2758274fe5cec54307902f857203bc61df07eaf
7
- data.tar.gz: be7099b617e6e8620db736ef2e2d18df2beace96c697f83bfb10d22ace83d3447a6d759132859237f0ca7182231d0032e23a8a1843e95b3cbbdbf1c65f9fa6ea
6
+ metadata.gz: 904031d93571d3d18113de6771b8ece8a85eebd220ec55053e920248ccde3c868771a62f842fb65ff32d3a42740a54d159ab5fd43f401b75d3aa104a59fd01cc
7
+ data.tar.gz: 76ec368394d7336a2f8082c48756e65fa1609d37c527fc8ddbadce6006ba8c8998f27bee7e6fab2d672b57630c453d0ae1c47e7732e3c404277b0c7345bf8f4e
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ inherit_gem:
4
4
  rubocop-bridgetown: .rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.7
7
+ TargetRubyVersion: 3.1
8
8
 
9
9
  Exclude:
10
10
  - Rakefile
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.1 / 2024-07-30
4
+
5
+ * Ensure esbuild output compiles away decorators
6
+
7
+ ## 3.0.0 / 2024-07-30
8
+
9
+ * Add collection name to preview title [#26] @thimy
10
+ * Add quick_search_content front matter overrides [#21] @copiousfreetime
11
+ * Add support for Bridgetown 2.0
12
+ * Switch to much improved esbuild build system for the repo
13
+
3
14
  ## 2.0.0 / 2022-10-08
4
15
 
5
16
  * Upgrade to new initializer system for Bridgetown 1.2
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.7.0"
19
+ spec.required_ruby_version = ">= 3.1.0"
20
20
 
21
- spec.add_dependency "bridgetown", ">= 1.2.0.beta2", "< 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
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 = "2.0.0"
5
+ VERSION = "3.0.1"
6
6
  end
7
7
  end
data/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "bridgetown-quick-search",
3
- "version": "2.0.0",
4
- "main": "frontend/javascript/index.js",
5
- "module": "frontend/javascript/index.js",
3
+ "version": "3.0.1",
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 --supported:decorators=false"
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
  }