jekyll-pagefind 0.2.0 → 0.2.1
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 +65 -13
- data/assets/linux-arm64/pagefind +0 -0
- data/assets/linux-x64/pagefind +0 -0
- data/assets/macos-arm64/pagefind +0 -0
- data/assets/macos-x64/pagefind +0 -0
- data/assets/windows-x64/pagefind.exe +0 -0
- data/jekyll-pagefind.gemspec +26 -0
- data/lib/jekyll/pagefind/version.rb +1 -1
- data/lib/jekyll-pagefind.rb +60 -11
- metadata +21 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da6350f1cdab2054988ffbd388592a97df71a8a193dd7c086c94f56f63073ae1
|
|
4
|
+
data.tar.gz: 41ef3c9bbb2e05ab8b7e960ba36f52bb444295f3bf209036635987917d7dc5c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84ceb9bcaeb5feaae2f28c00be44de3a03ceaa8eb26adf0f5060a22807558a0f50f8f4b81179438b88d6971e13cdf44f4089c6e1db3e2a0e4bd2ec8a8968070d
|
|
7
|
+
data.tar.gz: 8902b9fcb368cec056f541b07a92753e05b98862be590aaaa8ddbc649fc203bd01061919f9689f2836a14fbd5b55ca42842309c683778dddfca5377970560c6e
|
data/README.md
CHANGED
|
@@ -1,28 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 -->
|
|
2
|
+
<!-- markdownlint-disable MD041 -->
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://github.com/phothinmg/jekykll-pagefind/blob/main/rubygems_logo.png" width="160" height="160" alt="mmdevs" style="border-radius:50%" />
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">Jekyll::Pagefind</h1>
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
[](https://badge.fury.io/rb/jekyll-pagefind)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## Overview
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
Jekyll-Pagefind is a plugin I use for my personal and project sites. It was inspired by [Adding search to Jekyll using pagefind][pf_to_jekyll]. It fits easily into the default Jekyll GitHub Actions workflow for deploying to GitHub Pages.
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## Install
|
|
10
15
|
|
|
11
16
|
Install the gem and add to the application's Gemfile by executing:
|
|
12
17
|
|
|
13
|
-
```
|
|
14
|
-
bundle add
|
|
18
|
+
```sh
|
|
19
|
+
bundle add jekyll-pagefind
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bundle install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
In `Gemfile`
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
group :jekyll_plugins do
|
|
30
|
+
# other jekyll plugins
|
|
31
|
+
gem 'jekyll-pagefind' # add pagefind plugin
|
|
32
|
+
end
|
|
15
33
|
```
|
|
16
34
|
|
|
17
35
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
18
36
|
|
|
19
|
-
```
|
|
20
|
-
gem install
|
|
37
|
+
```sh
|
|
38
|
+
gem install jekyll-pagefind
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## How to
|
|
42
|
+
|
|
43
|
+
This guide is intended for Jekyll sites deployed to GitHub Pages.
|
|
44
|
+
|
|
45
|
+
### Download pagefind
|
|
46
|
+
|
|
47
|
+
First, download the standalone binary (`pagefind`) from the [pagefind releases][pf_release_page] page.
|
|
48
|
+
|
|
49
|
+
Make sure to use the correct binary:
|
|
50
|
+
|
|
51
|
+
1. For local development, download the standalone binary (`pagefind`) for your host platform.
|
|
52
|
+
2. For deployment to GitHub Pages, the binary must be `pagefind-v{version}-x86_64-unknown-linux-musl.tar.gz`.
|
|
53
|
+
|
|
54
|
+
### Place the binary file `pagefind`
|
|
55
|
+
|
|
56
|
+
Place the `pagefind` binary in the root of your Jekyll project, which is the recommended default, or anywhere else under the project root.
|
|
57
|
+
|
|
58
|
+
### Jekyll Config
|
|
59
|
+
|
|
60
|
+
**`_config.yml`**
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
plugins:
|
|
64
|
+
# other plugin
|
|
65
|
+
- jekyll-pagefind
|
|
21
66
|
```
|
|
22
67
|
|
|
23
|
-
|
|
68
|
+
If your `pagefind` binary is not in the project root, add this configuration option:
|
|
24
69
|
|
|
25
|
-
|
|
70
|
+
```yaml
|
|
71
|
+
pagefind: path_to_your/pagefind # where your `pagefind` was located
|
|
72
|
+
```
|
|
26
73
|
|
|
27
74
|
## Development
|
|
28
75
|
|
|
@@ -32,7 +79,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
32
79
|
|
|
33
80
|
## Contributing
|
|
34
81
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
82
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/phothinmg/jekyll-pagefind>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/phothinmg/jekyll-pagefind/blob/master/CODE_OF_CONDUCT.md).
|
|
36
83
|
|
|
37
84
|
## License
|
|
38
85
|
|
|
@@ -40,4 +87,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
40
87
|
|
|
41
88
|
## Code of Conduct
|
|
42
89
|
|
|
43
|
-
Everyone interacting in the Jekyll::Pagefind project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
|
90
|
+
Everyone interacting in the Jekyll::Pagefind project's codebases, 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).
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/jekyll/pagefind/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "jekyll-pagefind"
|
|
7
|
+
spec.version = Jekyll::Pagefind::VERSION
|
|
8
|
+
spec.authors = ["phothinmg"]
|
|
9
|
+
spec.email = ["phothinmg@disroot.org"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Pagefind plugin for Jekyll"
|
|
12
|
+
spec.description = "Run pagefind binary in jekyll site"
|
|
13
|
+
spec.homepage = "https://rubygems.org/gems/jekyll-pagefind"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/phothinmg/jekykll-pagefind"
|
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/phothinmg/jekykll-pagefind/blob/main/CHANGELOG.md"
|
|
19
|
+
|
|
20
|
+
spec.files = Dir.chdir(__dir__) do
|
|
21
|
+
Dir["README.md", "LICENSE.txt", "lib/**/*", "assets/**/*", "jekyll-pagefind.gemspec"]
|
|
22
|
+
end
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
spec.add_dependency "jekyll", "~> 4.4"
|
|
25
|
+
spec.add_dependency "open3", "~> 0.2.1"
|
|
26
|
+
end
|
data/lib/jekyll-pagefind.rb
CHANGED
|
@@ -1,22 +1,71 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "rbconfig"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "jekyll"
|
|
6
|
+
|
|
3
7
|
require_relative "jekyll/pagefind/version"
|
|
4
8
|
|
|
5
9
|
module Jekyll
|
|
10
|
+
# module Jekyll::Pagefind
|
|
6
11
|
module Pagefind
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
GEM_ROOT = File.expand_path("..", __dir__)
|
|
13
|
+
|
|
14
|
+
def self.pagefind_binary_path # rubocop:disable Metrics/MethodLength
|
|
15
|
+
os = RbConfig::CONFIG["host_os"]
|
|
16
|
+
cpu = RbConfig::CONFIG["host_cpu"]
|
|
17
|
+
|
|
18
|
+
case os
|
|
19
|
+
when /darwin|mac os/i
|
|
20
|
+
# Differentiate between Apple Silicon and Intel Macs
|
|
21
|
+
if cpu =~ /arm64|aarch64/i
|
|
22
|
+
File.join(GEM_ROOT, "assets", "macos-arm64",
|
|
23
|
+
"pagefind")
|
|
24
|
+
else
|
|
25
|
+
File.join(GEM_ROOT, "assets", "macos-x64", "pagefind")
|
|
18
26
|
end
|
|
27
|
+
when /linux/i
|
|
28
|
+
# Differentiate between standard servers and ARM instances
|
|
29
|
+
if cpu =~ /arm64|aarch64/i
|
|
30
|
+
File.join(GEM_ROOT, "assets", "linux-arm64",
|
|
31
|
+
"pagefind")
|
|
32
|
+
else
|
|
33
|
+
File.join(GEM_ROOT, "assets", "linux-x64", "pagefind")
|
|
34
|
+
end
|
|
35
|
+
# spellchecker:disable-next-line
|
|
36
|
+
when /mswin|msys|mingw|cygwin|bccwin/i
|
|
37
|
+
File.join(GEM_ROOT, "assets", "windows-x64", "pagefind.exe")
|
|
38
|
+
else
|
|
39
|
+
raise "Jekyll-PF Mismatch Error: Pagefind binary not provided for host environment: #{os} (#{cpu})"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.run_pagefind(site_destination) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
44
|
+
binary = pagefind_binary_path
|
|
45
|
+
|
|
46
|
+
# Force execution bits on UNIX hosts because gem unpacking can reset permissions flags
|
|
47
|
+
# spellchecker:disable-next-line
|
|
48
|
+
if RbConfig::CONFIG["host_os"] !~ /mswin|msys|mingw|cygwin|bccwin/i && !File.executable?(binary)
|
|
49
|
+
File.chmod(0o755, binary)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Run the indexer pointing explicitly at Jekyll's output directory
|
|
53
|
+
Jekyll.logger.info "Jekyll-PF:", "Starting Pagefind indexing on target folder..."
|
|
54
|
+
stdout, stderr, status = Open3.capture3("#{binary} --site \"#{site_destination}\"")
|
|
55
|
+
|
|
56
|
+
if status.success?
|
|
57
|
+
Jekyll.logger.info "Jekyll-PF:", "Indexing finished successfully!"
|
|
58
|
+
puts stdout
|
|
59
|
+
else
|
|
60
|
+
Jekyll.logger.error "Jekyll-PF Error:", stderr
|
|
61
|
+
raise "Pagefind binary exited with non-zero status code: #{status.exitstatus}"
|
|
19
62
|
end
|
|
20
63
|
end
|
|
21
64
|
end
|
|
22
65
|
end
|
|
66
|
+
|
|
67
|
+
# Hook ensures Jekyll is entirely done writing HTML pages to disk
|
|
68
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
|
69
|
+
# site.dest points dynamically to the configured destination folder (usually '_site')
|
|
70
|
+
Jekyll::Pagefind.run_pagefind(site.dest)
|
|
71
|
+
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.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- phothinmg
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '4.4'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: open3
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.2.1
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 0.2.1
|
|
26
40
|
description: Run pagefind binary in jekyll site
|
|
27
41
|
email:
|
|
28
42
|
- phothinmg@disroot.org
|
|
@@ -32,6 +46,12 @@ extra_rdoc_files: []
|
|
|
32
46
|
files:
|
|
33
47
|
- LICENSE.txt
|
|
34
48
|
- README.md
|
|
49
|
+
- assets/linux-arm64/pagefind
|
|
50
|
+
- assets/linux-x64/pagefind
|
|
51
|
+
- assets/macos-arm64/pagefind
|
|
52
|
+
- assets/macos-x64/pagefind
|
|
53
|
+
- assets/windows-x64/pagefind.exe
|
|
54
|
+
- jekyll-pagefind.gemspec
|
|
35
55
|
- lib/jekyll-pagefind.rb
|
|
36
56
|
- lib/jekyll/pagefind/version.rb
|
|
37
57
|
homepage: https://rubygems.org/gems/jekyll-pagefind
|