jekyll-meilisearch 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/jekyll-meilisearch/generator.rb +37 -6
- data/lib/jekyll-meilisearch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a72d0c48b806db86d5f211b3159947de63c62251159cb106e51bb511479af94
|
4
|
+
data.tar.gz: 22c93c7ccebd787cfbd368fa5f153e07557d598262ed57190be71a4ef66d0257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2095243088ae1c036775dc5b4f4c667000645f72d81f967fbefabd078f2639cdf1dbcf10cd20f03870db864219d450456e59bcf2bcfc1b812a15b0722ce56e1
|
7
|
+
data.tar.gz: be0979f777189fec3ad95da485a91eac4ae946698a95c0109b895b3ebceb8ea3264fc69f0bcee1647e4d144c54edd532f23dd1cb27030e3132455447dd81f5ba
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A Jekyll plugin that indexes your site’s content into Meilisearch, a fast and lightweight search engine. This plugin supports incremental indexing, ensuring efficient updates by only syncing changes between your Jekyll site and Meilisearch.
|
4
4
|
|
5
|
-
[](https://badge.fury.io/rb/jekyll-meilisearch)
|
6
6
|
|
7
7
|
## Features
|
8
8
|
- Indexes Jekyll collections (e.g., posts, pages) into Meilisearch.
|
@@ -72,8 +72,9 @@ Build your site. The plugin will:
|
|
72
72
|
- Create the Meilisearch index if it doesn’t exist.
|
73
73
|
- Fetch existing documents from Meilisearch.
|
74
74
|
- Delete obsolete documents.
|
75
|
-
- Index new or updated
|
75
|
+
- Index only new or updated collections defined in the config
|
76
76
|
- Logs will output to STDOUT with details about the indexing process.
|
77
|
+
- Skip indexing if the meilisearch host is unavailable
|
77
78
|
|
78
79
|
Include the following for adding search to your front :
|
79
80
|
```html
|
@@ -12,15 +12,49 @@ module JekyllMeilisearch
|
|
12
12
|
Jekyll.logger.info "Jekyll Meilisearch:", "Skipping meilisearch indexation in development"
|
13
13
|
return
|
14
14
|
end
|
15
|
+
|
16
|
+
# Skip indexing unless relevant files have changed in incremental mode
|
17
|
+
unless should_index?
|
18
|
+
Jekyll.logger.info "Jekyll Meilisearch:", "No relevant changes detected. Skipping indexing."
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
15
22
|
Jekyll.logger.info "Starting Meilisearch incremental indexing..."
|
16
23
|
return unless validate_config
|
17
24
|
|
18
|
-
|
19
|
-
|
25
|
+
begin
|
26
|
+
@documents = build_documents
|
27
|
+
sync_with_meilisearch
|
28
|
+
rescue StandardError => e
|
29
|
+
Jekyll.logger.error "Jekyll Meilisearch:", "Indexing failed due to an error: #{e.message}"
|
30
|
+
Jekyll.logger.info "Jekyll Meilisearch:", "Skipping Meilisearch indexing, but continuing Jekyll build."
|
31
|
+
nil
|
32
|
+
end
|
20
33
|
end
|
21
34
|
|
22
35
|
private
|
23
36
|
|
37
|
+
# Determine if indexing should occur based on changed files
|
38
|
+
def should_index?
|
39
|
+
# If not in incremental mode or first build, always index
|
40
|
+
return true unless @site.incremental?
|
41
|
+
|
42
|
+
# Get the collections to monitor from config
|
43
|
+
collections_config = config["collections"] || { "posts" => { "fields" => %w(title content url date) } }
|
44
|
+
monitored_collections = collections_config.keys
|
45
|
+
|
46
|
+
# Check if any changed files belong to the monitored collections
|
47
|
+
changed_files = @site.regenerator.modified_files
|
48
|
+
return false if changed_files.empty?
|
49
|
+
|
50
|
+
changed_files.any? do |file|
|
51
|
+
# Extract the relative path and check if it matches a collection
|
52
|
+
relative_path = file.relative_path.sub(%r!^/!, "")
|
53
|
+
collection_name = relative_path.split("/").first
|
54
|
+
monitored_collections.include?(collection_name)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
24
58
|
# Returns the plugin's config or an empty hash if not set
|
25
59
|
def config
|
26
60
|
@config ||= begin
|
@@ -61,7 +95,6 @@ module JekyllMeilisearch
|
|
61
95
|
id_format = collection_settings["id_format"] || :default
|
62
96
|
|
63
97
|
collection_docs = collection.docs.map do |doc|
|
64
|
-
# Skip if no front matter
|
65
98
|
next unless doc.data.any?
|
66
99
|
|
67
100
|
sanitized_id = generate_id(doc, collection_name, id_format)
|
@@ -134,8 +167,7 @@ module JekyllMeilisearch
|
|
134
167
|
loop do
|
135
168
|
response = attempt_request(
|
136
169
|
lambda {
|
137
|
-
HTTParty.get("#{url}/indexes/#{index_name}/documents?limit=#{limit}&offset=#{offset}", :headers => headers,
|
138
|
-
:timeout => 30)
|
170
|
+
HTTParty.get("#{url}/indexes/#{index_name}/documents?limit=#{limit}&offset=#{offset}", :headers => headers, :timeout => 30)
|
139
171
|
},
|
140
172
|
"fetching documents"
|
141
173
|
)
|
@@ -179,7 +211,6 @@ module JekyllMeilisearch
|
|
179
211
|
"indexing documents"
|
180
212
|
)
|
181
213
|
Jekyll.logger.info "Response code: #{response&.code}"
|
182
|
-
Jekyll.logger.info "Response response: #{response&.response}"
|
183
214
|
if response&.code == 202
|
184
215
|
if response.body
|
185
216
|
task = JSON.parse(response.body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-meilisearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unicolored
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|