jekyll-meilisearch 0.4.4 → 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 +43 -10
- data/lib/jekyll-meilisearch/version.rb +1 -1
- metadata +4 -3
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
|
)
|
@@ -164,7 +196,7 @@ module JekyllMeilisearch
|
|
164
196
|
if response&.success?
|
165
197
|
Jekyll.logger.info "Delete task queued successfully."
|
166
198
|
elsif response
|
167
|
-
Jekyll.logger.info "Failed to delete obsolete documents: #{response.code}
|
199
|
+
Jekyll.logger.info "Failed to delete obsolete documents: #{response.code}"
|
168
200
|
end
|
169
201
|
end
|
170
202
|
|
@@ -178,6 +210,7 @@ module JekyllMeilisearch
|
|
178
210
|
},
|
179
211
|
"indexing documents"
|
180
212
|
)
|
213
|
+
Jekyll.logger.info "Response code: #{response&.code}"
|
181
214
|
if response&.code == 202
|
182
215
|
if response.body
|
183
216
|
task = JSON.parse(response.body)
|
@@ -188,7 +221,7 @@ module JekyllMeilisearch
|
|
188
221
|
elsif response.nil?
|
189
222
|
Jekyll.logger.info "Failed to queue indexing task: No response received from Meilisearch."
|
190
223
|
else
|
191
|
-
Jekyll.logger.info "Failed to queue indexing task: #{response.code}
|
224
|
+
Jekyll.logger.info "Failed to queue indexing task: #{response.code}"
|
192
225
|
end
|
193
226
|
end
|
194
227
|
end
|
@@ -207,10 +240,10 @@ module JekyllMeilisearch
|
|
207
240
|
if response&.success? || response&.code == 202
|
208
241
|
Jekyll.logger.info "Index '#{index_name}' created successfully."
|
209
242
|
elsif response
|
210
|
-
Jekyll.logger.info "Failed to create index: #{response.code}
|
243
|
+
Jekyll.logger.info "Failed to create index: #{response.code}"
|
211
244
|
end
|
212
245
|
else
|
213
|
-
Jekyll.logger.info "Error checking index: #{response.code} - #{response.
|
246
|
+
Jekyll.logger.info "Error checking index: #{response.code} - #{response.response}"
|
214
247
|
end
|
215
248
|
end
|
216
249
|
|
@@ -224,7 +257,7 @@ module JekyllMeilisearch
|
|
224
257
|
if response.nil?
|
225
258
|
Jekyll.logger.info "Failed to reset index: No response received from Meilisearch."
|
226
259
|
else
|
227
|
-
Jekyll.logger.info "Failed to reset index: #{response.code}
|
260
|
+
Jekyll.logger.info "Failed to reset index: #{response.code}"
|
228
261
|
end
|
229
262
|
return
|
230
263
|
end
|
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
|
@@ -189,7 +189,8 @@ files:
|
|
189
189
|
homepage: https://github.com/unicolored/jekyll-meilisearch
|
190
190
|
licenses:
|
191
191
|
- MIT
|
192
|
-
metadata:
|
192
|
+
metadata:
|
193
|
+
source_code_uri: https://github.com/unicolored/jekyll-meilisearch
|
193
194
|
post_install_message:
|
194
195
|
rdoc_options: []
|
195
196
|
require_paths:
|