bridgetown-quick-search 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +13 -14
- data/bridgetown-quick-search.gemspec +4 -4
- data/components/bridgetown_quick_search/search.liquid +2 -1
- data/content/bridgetown_quick_search/index.json +10 -6
- data/lib/bridgetown-quick-search/version.rb +1 -1
- data/package.json +10 -11
- data/yarn.lock +182 -1397
- metadata +10 -12
- data/babel.config.js +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82f0598d813d41f5adf998da7b1215d26fba0f38a7e7a8cd2dc652585d61c561
|
4
|
+
data.tar.gz: 19cf61b695cf9b70db82ad90779b7471f3320bdd5b2f3c6c7b1df73f9b876c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b98df2b8a247dfad28afca8c73b2ca596754552c0fa27754cc8a791a1fae428a99877d546785ea9299e5508f32f593f5eaf33d80e4cd6a1ce7042f78c3f72039
|
7
|
+
data.tar.gz: e5b0940fff821ef9c5b7f52b93d8fdb515ae28fff609cbd2223a4f038b64fcc5914680d01397a53d24fcc2037cd0d90bc79611a66a6ba2fccce2b26832d86903
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
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
|
+
|
3
10
|
## 2.0.0 / 2022-10-08
|
4
11
|
|
5
12
|
* 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
|
12
|
+
$ bundle add bridgetown-quick-search
|
15
13
|
```
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
```js
|
20
|
-
// frontend/javascript/index.js
|
15
|
+
And then add the initializer to your configuration in `config/initializers.rb`:
|
21
16
|
|
22
|
-
|
17
|
+
```ruby
|
18
|
+
init :"bridgetown-quick-search"
|
23
19
|
```
|
24
20
|
|
25
|
-
|
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
|
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
|
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
|
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 = ">=
|
19
|
+
spec.required_ruby_version = ">= 3.1.0"
|
20
20
|
|
21
|
-
spec.add_dependency "bridgetown", ">= 1.2.0.beta2", "<
|
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.
|
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.
|
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.
|
12
|
-
{%-
|
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": {{
|
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": {{
|
47
|
+
"content": {{ content | strip_html | replace_regex: "[\s/\n]+"," " | strip | jsonify }}
|
44
48
|
}
|
45
49
|
{%- endunless %}
|
46
50
|
{%- endif %}
|
data/package.json
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "bridgetown-quick-search",
|
3
|
-
"version": "
|
4
|
-
"main": "frontend/
|
5
|
-
"module": "frontend/javascript/index.js",
|
3
|
+
"version": "3.0.0",
|
4
|
+
"main": "frontend/dist/index.js",
|
6
5
|
"exports": {
|
7
|
-
".": "./frontend/
|
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": "
|
28
|
+
"build": "esbuild frontend/javascript/index.js --bundle --outdir=frontend/dist --format=esm"
|
26
29
|
},
|
27
30
|
"dependencies": {
|
28
|
-
"
|
29
|
-
"lit": "^2.0.0",
|
31
|
+
"lit": "^3.1.0",
|
30
32
|
"lunr": "^2.3.8"
|
31
33
|
},
|
32
34
|
"devDependencies": {
|
33
|
-
"
|
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
|
}
|