jekyll-pagefind 0.2.1 → 0.3.0
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 +133 -35
- data/assets/windows-arm64/pagefind.exe +0 -0
- data/jekyll-pagefind.gemspec +2 -2
- data/lib/jekyll-pagefind.rb +56 -13
- data/lib/{jekyll/pagefind/version.rb → 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: 7354120e9ae2690548d13b7f1caca98d7d9565b3326c1dca67ec417c82c0be12
|
|
4
|
+
data.tar.gz: cb762ce2575300b20c80cba8c99e6dd3cc2981af14101b3f8e657679b9ed5197
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4110df9a227f32c095f5b569a59b103794c842f935ecb5ef717daa20cc87398ff8d1480a518601728bcc69ad9d3779e5fc3cb489fdac65d14561b50dfafcca65
|
|
7
|
+
data.tar.gz: 90a8d55735e526c12fed6cae896a9c1c03b19bd547a6c04c1039c216b34a851fbeed0846ad8603e7ebc270f774bca1c01732cf0669b2ff8174f1005cbf86fc57
|
data/README.md
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
<!-- markdownlint-disable MD033 -->
|
|
2
2
|
<!-- markdownlint-disable MD041 -->
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img src="https://
|
|
4
|
+
<img src="https://susee.phothin.dev/logo/rubygems_logo.png" width="160" height="160" alt="mmdevs" style="border-radius:50%" />
|
|
5
5
|
</p>
|
|
6
|
-
<h1 align="center">
|
|
6
|
+
<h1 align="center">jekyll-pagefind</h1>
|
|
7
7
|
|
|
8
8
|
[](https://badge.fury.io/rb/jekyll-pagefind)
|
|
9
9
|
|
|
10
10
|
## Overview
|
|
11
11
|
|
|
12
|
-
Jekyll-Pagefind is a plugin
|
|
12
|
+
Jekyll-Pagefind is a plugin that runs the Pagefind binary for a Jekyll site.
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
|
-
Install the gem and add to
|
|
16
|
+
Install the gem and add it to your application's Gemfile by running:
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
19
|
bundle add jekyll-pagefind
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
bundle install
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
In `Gemfile`
|
|
22
|
+
In your `Gemfile`:
|
|
27
23
|
|
|
28
24
|
```ruby
|
|
29
25
|
group :jekyll_plugins do
|
|
@@ -32,50 +28,157 @@ group :jekyll_plugins do
|
|
|
32
28
|
end
|
|
33
29
|
```
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
```sh
|
|
32
|
+
bundle install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If Bundler is not being used to manage dependencies, install the gem by running:
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
38
|
gem install jekyll-pagefind
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Use
|
|
42
|
+
|
|
43
|
+
### Jekyll site configuration
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
**`_config.yml`**
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
```yaml
|
|
48
|
+
plugins:
|
|
49
|
+
# other plugin
|
|
50
|
+
- jekyll-pagefind
|
|
51
|
+
# other config
|
|
52
|
+
# Optional Jekyll Pagefind Options
|
|
53
|
+
jekyll_pagefind:
|
|
54
|
+
output_subdir: pagefind
|
|
55
|
+
```
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
---
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
### Jekyll Pagefind options (optional)
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
2. For deployment to GitHub Pages, the binary must be `pagefind-v{version}-x86_64-unknown-linux-musl.tar.gz`.
|
|
61
|
+
These options map to the settings available in [Pagefind config files](https://pagefind.app/docs/config-sources/#:~:text=overriding%20configuration%20files.-,Config%20files,-Pagefind%20will%20look).
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
For more details, see [Pagefind CLI configuration options](https://pagefind.app/docs/config-options/). `jekyll_pagefind` supports the following options.
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
#### 1. output_subdir
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
The folder where the search bundle is written, relative to Jekyll `{{ site.dest }}`. The default is `pagefind`.
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
**Example:**
|
|
61
70
|
|
|
62
71
|
```yaml
|
|
63
|
-
|
|
64
|
-
# other plugin
|
|
65
|
-
- jekyll-pagefind
|
|
72
|
+
output_subdir: pf # becomes _site/pf
|
|
66
73
|
```
|
|
67
74
|
|
|
68
|
-
|
|
75
|
+
#### 2. exclude_selectors
|
|
76
|
+
|
|
77
|
+
Pass extra element selectors that Pagefind should ignore when indexing.
|
|
78
|
+
|
|
79
|
+
**Example :**
|
|
69
80
|
|
|
70
81
|
```yaml
|
|
71
|
-
|
|
82
|
+
exclude_selectors:
|
|
83
|
+
- "#my_navigation"
|
|
84
|
+
- "blockquote > span"
|
|
85
|
+
- "[id^='prefix-']"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### 3. keep_index_url
|
|
89
|
+
|
|
90
|
+
Keeps `index.html` at the end of search result paths. The default is `false`.
|
|
91
|
+
|
|
92
|
+
By default, a file at `animals/cat/index.html` will be given the URL `/animals/cat/`. Setting this option to true will result in the URL `/animals/cat/index.html`.
|
|
93
|
+
|
|
94
|
+
#### 4. quiet
|
|
95
|
+
|
|
96
|
+
Logs only errors and warnings while indexing the site.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Pagefind UI
|
|
101
|
+
|
|
102
|
+
#### 1. Using the Default UI
|
|
103
|
+
|
|
104
|
+
Using the Default UI is still supported, but it is no longer Pagefind's primary recommendation.
|
|
105
|
+
|
|
106
|
+
You can add the Pagefind UI to any page with the following snippet. The `/pagefind/` directory, or the directory specified by `output_subdir` in the [config](#1-output_subdir), will be created along with its files.
|
|
107
|
+
|
|
108
|
+
```liquid
|
|
109
|
+
<script src="{{ '/pagefind/pagefind-ui.js' | relative_url }}"></script>
|
|
110
|
+
<link rel="stylesheet" href="{{ '/pagefind/pagefind-ui.css' | relative_url }}" />
|
|
111
|
+
|
|
112
|
+
<div id="search"></div>
|
|
113
|
+
<script>
|
|
114
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
115
|
+
new PagefindUI({ element: "#search", showSubResults: true });
|
|
116
|
+
});
|
|
117
|
+
</script>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For dark mode:
|
|
121
|
+
|
|
122
|
+
```css
|
|
123
|
+
body.dark {
|
|
124
|
+
--pagefind-ui-primary: #eeeeee;
|
|
125
|
+
--pagefind-ui-text: #eeeeee;
|
|
126
|
+
--pagefind-ui-background: #152028;
|
|
127
|
+
--pagefind-ui-border: #152028;
|
|
128
|
+
--pagefind-ui-tag: #152028;
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
For more details, see [Using the Default UI](https://pagefind.app/docs/ui-usage/).
|
|
133
|
+
|
|
134
|
+
#### 2. Pagefind Component UI
|
|
135
|
+
|
|
136
|
+
Add the following snippet to `<head>`. The `/pagefind/` directory, or the directory specified by `output_subdir` in the [config](#1-output_subdir), will be created along with its files.
|
|
137
|
+
|
|
138
|
+
```liquid
|
|
139
|
+
<script src="{{ '/pagefind/pagefind-component-ui.js' | relative_url }}" type="module"></script>
|
|
140
|
+
<link rel="stylesheet" href="{{ '/pagefind/pagefind-component-ui.css' | relative_url }}" />
|
|
72
141
|
```
|
|
73
142
|
|
|
74
|
-
|
|
143
|
+
For dark mode:
|
|
75
144
|
|
|
76
|
-
|
|
145
|
+
```html
|
|
146
|
+
<div data-pf-theme="dark">
|
|
147
|
+
<pagefind-searchbox></pagefind-searchbox>
|
|
148
|
+
</div>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```css
|
|
152
|
+
@media (prefers-color-scheme: dark) {
|
|
153
|
+
:root {
|
|
154
|
+
--pf-text: #e5e5e5;
|
|
155
|
+
--pf-text-secondary: #a0a0a0;
|
|
156
|
+
--pf-text-muted: #949494;
|
|
157
|
+
--pf-background: #1a1a1a;
|
|
158
|
+
--pf-border: #333;
|
|
159
|
+
--pf-border-focus: #555;
|
|
160
|
+
--pf-skeleton: #2a2a2a;
|
|
161
|
+
--pf-skeleton-shine: #333;
|
|
162
|
+
--pf-hover: #252525;
|
|
163
|
+
--pf-mark: #e5e5e5;
|
|
164
|
+
--pf-scroll-shadow: rgba(255, 255, 255, 0.1);
|
|
165
|
+
--pf-outline-focus: #58a6ff;
|
|
166
|
+
|
|
167
|
+
--pf-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
168
|
+
--pf-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
|
|
169
|
+
--pf-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
|
|
170
|
+
|
|
171
|
+
--pf-error-bg: #2a1a1a;
|
|
172
|
+
--pf-error-border: #5c2828;
|
|
173
|
+
--pf-error-text: #f87171;
|
|
174
|
+
--pf-error-text-secondary: #ef4444;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
77
178
|
|
|
78
|
-
|
|
179
|
+
For more details, see [Using the Default UI](https://pagefind.app/docs/search-ui/).
|
|
180
|
+
|
|
181
|
+
---
|
|
79
182
|
|
|
80
183
|
## Contributing
|
|
81
184
|
|
|
@@ -87,9 +190,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
87
190
|
|
|
88
191
|
## Code of Conduct
|
|
89
192
|
|
|
90
|
-
Everyone interacting in the Jekyll::Pagefind project's
|
|
91
|
-
|
|
92
|
-
<!-- markdownlint-disable MD053 -->
|
|
93
|
-
|
|
94
|
-
[pf_release_page]: https://github.com/Pagefind/pagefind/releases/latest
|
|
95
|
-
[pf_to_jekyll]: https://www.bfoliver.com/2025/pagefind
|
|
193
|
+
Everyone interacting in the Jekyll::Pagefind project's codebase, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/phothinmg/jekyll-pagefind/blob/master/CODE_OF_CONDUCT.md).
|
|
Binary file
|
data/jekyll-pagefind.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "lib/
|
|
3
|
+
require_relative "lib/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "jekyll-pagefind"
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = "Run pagefind binary in jekyll site"
|
|
13
13
|
spec.homepage = "https://rubygems.org/gems/jekyll-pagefind"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = ">= 3.
|
|
15
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/phothinmg/jekykll-pagefind"
|
|
18
18
|
spec.metadata["changelog_uri"] = "https://github.com/phothinmg/jekykll-pagefind/blob/main/CHANGELOG.md"
|
data/lib/jekyll-pagefind.rb
CHANGED
|
@@ -4,14 +4,14 @@ require "rbconfig"
|
|
|
4
4
|
require "open3"
|
|
5
5
|
require "jekyll"
|
|
6
6
|
|
|
7
|
-
require_relative "
|
|
7
|
+
require_relative "version"
|
|
8
8
|
|
|
9
9
|
module Jekyll
|
|
10
10
|
# module Jekyll::Pagefind
|
|
11
11
|
module Pagefind
|
|
12
12
|
GEM_ROOT = File.expand_path("..", __dir__)
|
|
13
13
|
|
|
14
|
-
def self.pagefind_binary_path # rubocop:disable Metrics/MethodLength
|
|
14
|
+
def self.pagefind_binary_path # rubocop:disable Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
15
15
|
os = RbConfig::CONFIG["host_os"]
|
|
16
16
|
cpu = RbConfig::CONFIG["host_cpu"]
|
|
17
17
|
|
|
@@ -34,13 +34,52 @@ module Jekyll
|
|
|
34
34
|
end
|
|
35
35
|
# spellchecker:disable-next-line
|
|
36
36
|
when /mswin|msys|mingw|cygwin|bccwin/i
|
|
37
|
-
|
|
37
|
+
# Differentiate between Intel/AMD and ARM Windows machines
|
|
38
|
+
if cpu =~ /arm64|aarch64/i
|
|
39
|
+
File.join(GEM_ROOT, "assets", "windows-arm64", "pagefind.exe")
|
|
40
|
+
else
|
|
41
|
+
File.join(GEM_ROOT, "assets", "windows-x64", "pagefind.exe")
|
|
42
|
+
end
|
|
38
43
|
else
|
|
39
|
-
raise "Jekyll-
|
|
44
|
+
raise "Jekyll-Pagefind Mismatch Error: Pagefind binary not provided for host environment: #{os} (#{cpu})"
|
|
40
45
|
end
|
|
41
46
|
end
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
# valid the cli flag
|
|
49
|
+
def self.valid_args(arg)
|
|
50
|
+
%w[output_subdir exclude_selectors keep_index_url quiet].include?(arg)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Converts Jekyll config options into matching Pagefind command line flags
|
|
54
|
+
def self.build_cli_arguments(config) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity
|
|
55
|
+
plugin_config = config["jekyll_pagefind"] || {}
|
|
56
|
+
args = []
|
|
57
|
+
|
|
58
|
+
plugin_config.each do |key, value|
|
|
59
|
+
next unless valid_args(key)
|
|
60
|
+
|
|
61
|
+
# Transform snake_case keys to kebab-case (e.g., keep_index_url -> keep-index-url)
|
|
62
|
+
flag_name = key.to_s.gsub("_", "-")
|
|
63
|
+
|
|
64
|
+
case value
|
|
65
|
+
when TrueClass
|
|
66
|
+
# Boolean flags like --keep-index-url require no attached value
|
|
67
|
+
args << "--#{flag_name}"
|
|
68
|
+
when FalseClass
|
|
69
|
+
# Ignore false booleans unless Pagefind specifically supports a negative override
|
|
70
|
+
next
|
|
71
|
+
when Array
|
|
72
|
+
# Arrays like exclude_selectors need to be repeated: --exclude-selectors ".footer" --exclude-selectors "nav"
|
|
73
|
+
value.each { |val| args << "--#{flag_name} \"#{val}\"" }
|
|
74
|
+
else
|
|
75
|
+
# Strings or numbers like --bundle-dir "search"
|
|
76
|
+
args << "--#{flag_name} \"#{value}\""
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
args.join(" ")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def self.run_pagefind(site_destination, extra_arguments = "") # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
44
83
|
binary = pagefind_binary_path
|
|
45
84
|
|
|
46
85
|
# Force execution bits on UNIX hosts because gem unpacking can reset permissions flags
|
|
@@ -49,15 +88,17 @@ module Jekyll
|
|
|
49
88
|
File.chmod(0o755, binary)
|
|
50
89
|
end
|
|
51
90
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
91
|
+
# Combine the mandatory --site parameter with any user-defined configuration flags
|
|
92
|
+
full_command = "#{binary} --site \"#{site_destination}\" #{extra_arguments}".strip
|
|
93
|
+
|
|
94
|
+
Jekyll.logger.info "Jekyll-Pagefind:", "Running command: #{full_command}"
|
|
95
|
+
stdout, stderr, status = Open3.capture3(full_command)
|
|
55
96
|
|
|
56
97
|
if status.success?
|
|
57
|
-
Jekyll.logger.info "Jekyll-
|
|
98
|
+
Jekyll.logger.info "Jekyll-Pagefind:", "Indexing finished successfully!"
|
|
58
99
|
puts stdout
|
|
59
100
|
else
|
|
60
|
-
Jekyll.logger.error "Jekyll-
|
|
101
|
+
Jekyll.logger.error "Jekyll-Pagefind Error:", stderr
|
|
61
102
|
raise "Pagefind binary exited with non-zero status code: #{status.exitstatus}"
|
|
62
103
|
end
|
|
63
104
|
end
|
|
@@ -66,6 +107,8 @@ end
|
|
|
66
107
|
|
|
67
108
|
# Hook ensures Jekyll is entirely done writing HTML pages to disk
|
|
68
109
|
Jekyll::Hooks.register :site, :post_write do |site|
|
|
69
|
-
#
|
|
70
|
-
Jekyll::Pagefind.
|
|
71
|
-
|
|
110
|
+
# 1. Parse your plugin settings out of site.config
|
|
111
|
+
custom_flags = Jekyll::Pagefind.build_cli_arguments(site.config)
|
|
112
|
+
# 2. Run Pagefind with the compiled flags
|
|
113
|
+
Jekyll::Pagefind.run_pagefind(site.dest, custom_flags)
|
|
114
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-pagefind
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- phothinmg
|
|
@@ -50,10 +50,11 @@ files:
|
|
|
50
50
|
- assets/linux-x64/pagefind
|
|
51
51
|
- assets/macos-arm64/pagefind
|
|
52
52
|
- assets/macos-x64/pagefind
|
|
53
|
+
- assets/windows-arm64/pagefind.exe
|
|
53
54
|
- assets/windows-x64/pagefind.exe
|
|
54
55
|
- jekyll-pagefind.gemspec
|
|
55
56
|
- lib/jekyll-pagefind.rb
|
|
56
|
-
- lib/
|
|
57
|
+
- lib/version.rb
|
|
57
58
|
homepage: https://rubygems.org/gems/jekyll-pagefind
|
|
58
59
|
licenses:
|
|
59
60
|
- MIT
|
|
@@ -68,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
68
69
|
requirements:
|
|
69
70
|
- - ">="
|
|
70
71
|
- !ruby/object:Gem::Version
|
|
71
|
-
version: 3.
|
|
72
|
+
version: 3.1.0
|
|
72
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
requirements:
|
|
74
75
|
- - ">="
|