jekyll-meilisearch 0.4.5 → 0.4.7
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 +45 -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: '09cff948b7ec1b219157c7c66c47592cfb3696fe4c338bb2b107878bfeda315f'
|
4
|
+
data.tar.gz: a706dd8eff495d9225006a5c0f6c73ccb5210580a2b2898228a4614acfd2863c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d0e8a496a93775fde2f7d913e54afee9db82c50ab8795615473969ddd1bb5c85e411918854dbd1ce9fc5709abcab48b44c1b14866b8f2b5edb526d655ba161
|
7
|
+
data.tar.gz: b90285171c4d20d388b86dedb0a4254ebb19f9a572d3c8d7d3edc7d7ee4209c2ee3f7724bcc6cb36b60e107db12c51b2fedbe436a0bf3941014763a6a05c1397
|
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,57 @@ 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
|
+
# Always index if not in incremental mode (full build)
|
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 regenerator supports modified_files (Jekyll version compatibility)
|
47
|
+
if @site.regenerator.respond_to?(:modified_files)
|
48
|
+
changed_files = @site.regenerator.modified_files
|
49
|
+
return false if changed_files.empty?
|
50
|
+
|
51
|
+
changed_files.any? do |file|
|
52
|
+
relative_path = file.relative_path.sub(%r!^/!, "")
|
53
|
+
collection_name = relative_path.split("/").first
|
54
|
+
is_in_collection = @site.collections.key?(collection_name) && monitored_collections.include?(collection_name)
|
55
|
+
Jekyll.logger.info "Jekyll Meilisearch:",
|
56
|
+
"File: #{relative_path}, Collection: #{collection_name}, In monitored collection? #{is_in_collection}"
|
57
|
+
is_in_collection
|
58
|
+
end
|
59
|
+
else
|
60
|
+
# Fallback: Warn and assume indexing is needed if we can’t check changes
|
61
|
+
Jekyll.logger.warn "Jekyll Meilisearch:", "Incremental change detection not supported in this Jekyll version. Indexing all documents."
|
62
|
+
true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
24
66
|
# Returns the plugin's config or an empty hash if not set
|
25
67
|
def config
|
26
68
|
@config ||= begin
|
@@ -61,7 +103,6 @@ module JekyllMeilisearch
|
|
61
103
|
id_format = collection_settings["id_format"] || :default
|
62
104
|
|
63
105
|
collection_docs = collection.docs.map do |doc|
|
64
|
-
# Skip if no front matter
|
65
106
|
next unless doc.data.any?
|
66
107
|
|
67
108
|
sanitized_id = generate_id(doc, collection_name, id_format)
|
@@ -134,8 +175,7 @@ module JekyllMeilisearch
|
|
134
175
|
loop do
|
135
176
|
response = attempt_request(
|
136
177
|
lambda {
|
137
|
-
HTTParty.get("#{url}/indexes/#{index_name}/documents?limit=#{limit}&offset=#{offset}", :headers => headers,
|
138
|
-
:timeout => 30)
|
178
|
+
HTTParty.get("#{url}/indexes/#{index_name}/documents?limit=#{limit}&offset=#{offset}", :headers => headers, :timeout => 30)
|
139
179
|
},
|
140
180
|
"fetching documents"
|
141
181
|
)
|
@@ -179,7 +219,6 @@ module JekyllMeilisearch
|
|
179
219
|
"indexing documents"
|
180
220
|
)
|
181
221
|
Jekyll.logger.info "Response code: #{response&.code}"
|
182
|
-
Jekyll.logger.info "Response response: #{response&.response}"
|
183
222
|
if response&.code == 202
|
184
223
|
if response.body
|
185
224
|
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.7
|
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
|