jekyll-linked-posts 0.1.0 → 0.2.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: e6fd76736e5b6a0ad623396a4fdcbae2ecade1d238c543d230f9838db8676d0f
4
- data.tar.gz: 9574fc8c1000bdb034ec270d512b63e3d08c0c4f85239dd8a70ad68417251255
3
+ metadata.gz: 567b5bf4cd5fbc9ed6b521ed1a76d6b609ac4bdd0d5e61b01f963ffe81ec6229
4
+ data.tar.gz: 9fbca911800e53b4259be09b74d82c8d96e8e59c555a276b774310bf4b90cab1
5
5
  SHA512:
6
- metadata.gz: 1460920ac472f1c6507315ab62f5bb8b257bdb2e9e14bc783a662bcc9fc7b259d255b32cefcf300946f8e8900d1e54a8297e3b07622273c1e28ec60d8a6937cf
7
- data.tar.gz: 1807a345bcaeaf0603bf6da6c9a7a7865cd185497a304a48923a3fb255fab72dd1c0fd2e89a9eaca0f8d1bc737a3c38a6b23b409cc91757d75959a02732e7124
6
+ metadata.gz: 0d52bf528f5ad92507d44c698321e95cdfc7b1bd6506b5c618f6f4aafea9e97d2fdf76b56b0288653e4eeb1611b5541a19f22f4c776cafd78b82143d24cc46ae
7
+ data.tar.gz: f1ecddd44fcc19576bbc58382df7371587ab3bcd60bb4c5b3ff74fc26c0a7af48d574324714633a24f13bf5310359ea76f27780c17121d8dd11997a4dea55ef9
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.0 - 2020-09-03
4
+
5
+ * Breadcrumbs!
6
+
3
7
  ## v0.1.0 - 2020-05-20
4
8
 
5
9
  * First release!
data/README.md CHANGED
@@ -90,6 +90,29 @@ them with other fields, re-add them to the configuration.
90
90
 
91
91
  It also works between collections!
92
92
 
93
+ ## Breadcrumbs
94
+
95
+ If you're linking articles by the same field, you can create
96
+ a breadcrumb like this:
97
+
98
+ ```html
99
+ {%- assign breadcrumbs = page | breadcrumbs: 'previous' -%}
100
+
101
+ <nav aria-label="Breadcrumbs">
102
+ <ol class="breadcrumb">
103
+ {% for crumb in breadcrumbs %}
104
+ {% if forloop.last %}
105
+ <li class="breadcrumb-item active" aria-current="page">{{ crumb.title }}</li>
106
+ {% else %}
107
+ <li class="breadcrumb-item">
108
+ <a href="{{ crumb.url }}">{{ crumb.title }}</a>
109
+ </li>
110
+ {% endif %}
111
+ {% endfor %}
112
+ </ol>
113
+ </nav>
114
+ ```
115
+
93
116
  ## Contributing
94
117
 
95
118
  Bug reports and pull requests are welcome on 0xacab.org at
@@ -98,6 +121,9 @@ intended to be a safe, welcoming space for collaboration, and
98
121
  contributors are expected to adhere to the [Sutty code of
99
122
  conduct](https://sutty.nl/en/code-of-conduct/).
100
123
 
124
+ If you like our plugins, [please consider
125
+ donating](https://donaciones.sutty.nl/en/)!
126
+
101
127
  ## License
102
128
 
103
129
  The gem is available as free software under the terms of the GPL3
@@ -1,4 +1,5 @@
1
1
  require_relative 'jekyll/linked_posts'
2
+ require_relative 'jekyll/filters/breadcrumbs'
2
3
 
3
4
  # Process the site replacing UUIDs for posts in certain front matter fields
4
5
  Jekyll::Hooks.register :site, :post_read do |site|
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Filters
5
+ module Breadcrumbs
6
+ # The breadcrumbs filter returns an Array of Jekyll::Documents
7
+ # that are linked recursively by the same field.
8
+ #
9
+ # @param [Jekyll::Document]
10
+ # @param [String]
11
+ # @return [Array]
12
+ def breadcrumbs(input, field)
13
+ return unless input.respond_to? :[]
14
+
15
+ crumbs = [ input ]
16
+ prev = input
17
+
18
+ while prev&.public_send(:[], field)
19
+ crumbs << (prev = prev[field])
20
+ end
21
+
22
+ crumbs.reverse
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ Liquid::Template.register_filter(Jekyll::Filters::Breadcrumbs)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-linked-posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -38,6 +38,7 @@ files:
38
38
  - LICENSE.txt
39
39
  - README.md
40
40
  - lib/jekyll-linked-posts.rb
41
+ - lib/jekyll/filters/breadcrumbs.rb
41
42
  - lib/jekyll/linked_posts.rb
42
43
  homepage: https://0xacab.org/sutty/jekyll/jekyll-linked-posts
43
44
  licenses:
@@ -48,7 +49,7 @@ metadata:
48
49
  source_code_uri: https://0xacab.org/sutty/jekyll/jekyll-linked-posts
49
50
  changelog_uri: https://0xacab.org/sutty/jekyll/jekyll-linked-posts/-/blob/master/CHANGELOG.md
50
51
  documentation_uri: https://rubydoc.info/gems/jekyll-linked-posts
51
- post_install_message:
52
+ post_install_message:
52
53
  rdoc_options:
53
54
  - "--title"
54
55
  - jekyll-linked-posts - Adds linked posts to Jekyll
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  version: '0'
72
73
  requirements: []
73
74
  rubygems_version: 3.0.3
74
- signing_key:
75
+ signing_key:
75
76
  specification_version: 4
76
77
  summary: Adds linked posts to Jekyll
77
78
  test_files: []