jekyll-alternate-permalinks 0.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 424645ac87621f2b249e4e523f3f44ebd5f6cfd25566faba573ba675a040b6b3
4
- data.tar.gz: 687b40f77e034622c2f2aada3acb966e814f1cbe17bc131519754dc630aee4d0
3
+ metadata.gz: 0efc14428c38cdff9b73ef8d6802840072180aa08ba2993e44d44c4258aa6417
4
+ data.tar.gz: 3da9167059fb389e6cb3ad2da11bb92c56a46cd5d035d183e923038aafff20d9
5
5
  SHA512:
6
- metadata.gz: 3b995e5c0a8d75756355fa4bac679e27593e29434478d319803df846450ef70f9534ba6a5e5fd3bc3b3186f605c0a8f2ccaed716be4b8b4f5deae2785b108ce3
7
- data.tar.gz: 304183e38061f36c2a3085d2ea7334a88792e853db3944807e35135efbd1d0586cb05d0272ec04779da2e27bad2a21b29bfec432283586963fc540c2f92701f2
6
+ metadata.gz: e4d97dd97e2e0c27cd2e356f7540fb81a7e49c3764cc944d72ff61e71fe2cb93abc84123d57570815f8ed1f06c1d051307b1d5be8aeeb8898c1b9831e1e5ea3c
7
+ data.tar.gz: d905f78964c4b9eccb5dae8f424a4aeb07b784eec470e44293f1119b941e45028a2466b3b1e876332f12882c7525bbf6e496b354b34ec7b3b413b5831201f1a7
checksums.yaml.gz.sig ADDED
Binary file
data/README.md CHANGED
@@ -34,8 +34,8 @@ plugins:
34
34
 
35
35
  ### In pages and posts
36
36
 
37
- Add the `alternate-permalinks` array to any file that supports a front
38
- matter (pages, collections, posts).
37
+ Add the `alternate-permalinks` or `alternate_permalinks` array to any
38
+ file that supports a front matter (pages, collections, posts).
39
39
 
40
40
  ```yaml
41
41
  ---
@@ -2,31 +2,37 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- # TODO: For extra boilerplate's sake (!), convert to a class that
6
- # renders as symlink
7
- #
8
- # TODO: Use hardlinks? There won't be a "canonical" file because they
9
- # all will be the same file, but the site would work on filesystems that
10
- # don't support symlinks.
11
- Jekyll::Hooks.register :site, :post_write do |site|
12
- # Traverse all files that could contain alternate-permalinks
13
- [site.pages, site.documents].flatten.each do |page|
14
- # Get a pathname for the file
15
- path = Pathname.new page.destination site.dest
16
-
17
- # Create a symlink for each alternate permalink
18
- page.data['alternate-permalinks']&.each do |alt|
19
- alt = Jekyll::PathManager.join(alt, 'index.html') if alt.end_with? '/'
20
-
21
- alt_path = Pathname.new site.in_dest_dir(alt)
22
-
23
- if File.exist? alt_path
24
- Jekyll.logger.warn "#{alt_path} already exists, skipping"
25
- else
26
- Jekyll.logger.debug "Symlink from #{path.relative_path_from(alt_path.dirname)} to #{alt}"
27
-
28
- FileUtils.mkdir_p(alt_path.dirname)
29
- File.symlink path.relative_path_from(alt_path.dirname), alt_path
5
+ module Jekyll
6
+ module AlternatePermalinks
7
+ extend self
8
+
9
+ def render(page)
10
+ alternate_permalinks = page.data['alternate-permalinks']
11
+ alternate_permalinks ||= page.data['alternate_permalinks']
12
+
13
+ return unless alternate_permalinks.is_a? Array
14
+
15
+ site = page.site
16
+
17
+ # Get a pathname for the file
18
+ path = Pathname.new(page.destination(site.dest))
19
+
20
+ # Create a symlink for each alternate permalink
21
+ alternate_permalinks.each do |alt|
22
+ alt = Jekyll::PathManager.join(alt, 'index.html') if alt.end_with? '/'
23
+
24
+ alt_path = Pathname.new(site.in_dest_dir(alt))
25
+
26
+ if alt_path.exist?
27
+ Jekyll.logger.warn 'Permalinks:', "#{alt_path} already exists, skipping"
28
+ else
29
+ relative_path = path.relative_path_from(alt_path.dirname)
30
+
31
+ Jekyll.logger.info 'Permalinks:', "Symlink from #{relative_path} to #{alt}"
32
+
33
+ FileUtils.mkdir_p(alt_path.dirname)
34
+ File.symlink(relative_path, alt_path)
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -1,3 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'jekyll/alternate/permalinks'
4
+
5
+ Jekyll::Hooks.register :documents, :post_write do |document|
6
+ Jekyll::AlternatePermalinks.render document
7
+ end
8
+
9
+ Jekyll::Hooks.register :pages, :post_write do |page|
10
+ Jekyll::AlternatePermalinks.render page
11
+ end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-alternate-permalinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2020-10-26 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEYDCCAsigAwIBAgIBATANBgkqhkiG9w0BAQsFADA7MQ4wDAYDVQQDDAVmYXVu
14
+ bzEVMBMGCgmSJomT8ixkARkWBXN1dHR5MRIwEAYKCZImiZPyLGQBGRYCbmwwHhcN
15
+ MjUwMTA3MTczMTQ1WhcNMjYwMTA3MTczMTQ1WjA7MQ4wDAYDVQQDDAVmYXVubzEV
16
+ MBMGCgmSJomT8ixkARkWBXN1dHR5MRIwEAYKCZImiZPyLGQBGRYCbmwwggGiMA0G
17
+ CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDqrFZ8PCNQbaW1incHEZp/OZTIt7bZ
18
+ TMKmkVLeRDqsSBGWTGdZbzRS6idn0vUKlTTnclPPG7dXw1r+AiYVdwIdjx16SLV1
19
+ ipbT/ezdzchfBVQHqdvExszAlL689iUnM9r22KkAXSzidSWuySjA5BY+8p1S2QO5
20
+ NcuB/+R5JRybVn6g500EB60jAZNUMM+2OlDqzS7oVqObOZ8zl8/HJaJnBGNNYLbN
21
+ cUY6qV9/0HUD2fS/eidBUGhg4jPKWHLHOZuXHPmGyE8bqdKC9T+Jbk/8KFM+SW7B
22
+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  description: Prevents broken links when renaming articles by keeping a list of previous
14
41
  permalinks and creating links between them
@@ -58,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
85
  - !ruby/object:Gem::Version
59
86
  version: '0'
60
87
  requirements: []
61
- rubygems_version: 3.1.2
88
+ rubygems_version: 3.3.27
62
89
  signing_key:
63
90
  specification_version: 4
64
91
  summary: Creates links from previous permalinks to the current one
metadata.gz.sig ADDED
Binary file