jekyll-group 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe61a07b981e56547a789bdf64a0dccaf75af2d47cc5322807fd5e9d3154cb89
4
+ data.tar.gz: da5833ceca1ce204de8459eaed6698f849931d63c0ba0608c51b93afe4a0c469
5
+ SHA512:
6
+ metadata.gz: abe9797211068dfbc1b2e17e91c199fa5745e810a45d17935555229de4d2600832278376668a82d0c1a25698d0634c960481d87e4ee78bb6ef4f26edcb8f5920
7
+ data.tar.gz: 1632954755c4d589f0b88a3bbf763d09827208f5ea62f5417265003c883d0593cc3f937e7dbc1e79306db8b99ffda24fccf6c2624eb577f74fb6aa4cc93ae074
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2021 Rob Miller <r@robm.me.uk>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "jekyll-group/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-group"
7
+ spec.summary = "Jekyll plugin for making posts part of a wider series"
8
+ spec.description = "Jekyll plugin for making posts part of a chronological series of posts that can be navigated through."
9
+ spec.version = JekyllGroup::VERSION
10
+ spec.authors = ["Rob Miller"]
11
+ spec.email = ["r@robm.me.uk"]
12
+ spec.homepage = "https://github.com/robmiller/jekyll-group"
13
+ spec.licenses = ["MIT"]
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
15
+ spec.require_paths = ["lib"]
16
+ spec.add_dependency "jekyll", "~> 4.0"
17
+ spec.add_development_dependency "rake", "~> 11.0"
18
+ end
@@ -0,0 +1,3 @@
1
+ require_relative "jekyll-group/version"
2
+ require_relative "jekyll-group/generator"
3
+ require_relative "jekyll-group/tag"
@@ -0,0 +1,41 @@
1
+ module JekyllGroup
2
+ class Generator < Jekyll::Generator
3
+ safe true
4
+ priority :lowest
5
+
6
+ def generate(site)
7
+ @site = site
8
+ group_posts
9
+ generate_groups
10
+
11
+ @site.posts.docs.each do |post|
12
+ next unless post.data["group"]
13
+
14
+ group_slug = post.data["group"]
15
+ post.data["group"] = groups[group_slug]
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :groups
22
+ attr_reader :posts_by_group
23
+
24
+ def generate_groups
25
+ @groups =
26
+ @site.posts.docs
27
+ .map { |p| p.data["group"] }
28
+ .compact
29
+ .uniq
30
+ .map { |g| [g, { "slug" => g, "posts" => posts_by_group[g] }] }
31
+ .to_h
32
+ end
33
+
34
+ def group_posts
35
+ @posts_by_group =
36
+ @site.posts.docs
37
+ .select { |p| p.data["group"] }
38
+ .group_by { |p| p.data["group"] }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ module JekyllGroup
2
+ class PostGroupTag < Liquid::Tag
3
+ def render(context)
4
+ page = context["page"]
5
+ group = page["group"]
6
+
7
+ return "" unless group
8
+
9
+ liquid = <<~EOL
10
+ <h3>Part of the {{ page.group.slug }} series</h3>
11
+ <ol>
12
+ {% for post in page.group.posts %}
13
+ {% if post.id == page.id %}
14
+ <li>{{ post.title }}</li>
15
+ {% else %}
16
+ <li><a href="{{ post.url | absolute_url }}">{{ post.title }}</a></li>
17
+ {% endif %}
18
+ {% endfor %}
19
+ </ol>
20
+ EOL
21
+
22
+ partial = Liquid::Template.parse(liquid)
23
+ context.stack do
24
+ partial.render(context)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ Liquid::Template.register_tag("post_group", JekyllGroup::PostGroupTag)
@@ -0,0 +1,3 @@
1
+ module JekyllGroup
2
+ VERSION = "0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-group
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Rob Miller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ description: Jekyll plugin for making posts part of a chronological series of posts
42
+ that can be navigated through.
43
+ email:
44
+ - r@robm.me.uk
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - LICENSE
50
+ - jekyll-group.gemspec
51
+ - lib/jekyll-group.rb
52
+ - lib/jekyll-group/generator.rb
53
+ - lib/jekyll-group/tag.rb
54
+ - lib/jekyll-group/version.rb
55
+ homepage: https://github.com/robmiller/jekyll-group
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.2.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Jekyll plugin for making posts part of a wider series
78
+ test_files: []