jekyll-breadcrumbs-tag 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd042d43ddc891227e4d5122bb4c3224e9c14f008e9c14dfb71f4b364cc28801
4
+ data.tar.gz: 397ed07ee0b102b323826cf6da3d21a14f059df545a577353434a5decd0027a6
5
+ SHA512:
6
+ metadata.gz: e2e60532715d1211b8615d40c77e4d5a67ca4b87d96366db47ae1856ca425239f7158de9cb521c9b1d62330045328fbbef855210cb0cbccd3adb7114aa103a23
7
+ data.tar.gz: 7c1ae493eefcfb982c0a2da3fafc5c988a47f9cf59e5b9dfcc632acf3390db7973cb999ef94bb512d8ed618be071a1fbdd2d6b46eac68798715765e127d4d1e3
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --require rspec-power_assert
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in jekyll-gsnippet-tag.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec"
10
+ gem "rspec-power_assert"
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jekyll-breadcrumbs-tag (0.1.0)
5
+ jekyll
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.1)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ colorator (1.1.0)
13
+ concurrent-ruby (1.1.10)
14
+ diff-lcs (1.5.0)
15
+ em-websocket (0.5.3)
16
+ eventmachine (>= 0.12.9)
17
+ http_parser.rb (~> 0)
18
+ eventmachine (1.2.7)
19
+ ffi (1.15.5)
20
+ forwardable-extended (2.6.0)
21
+ http_parser.rb (0.8.0)
22
+ i18n (1.12.0)
23
+ concurrent-ruby (~> 1.0)
24
+ jekyll (4.2.2)
25
+ addressable (~> 2.4)
26
+ colorator (~> 1.0)
27
+ em-websocket (~> 0.5)
28
+ i18n (~> 1.0)
29
+ jekyll-sass-converter (~> 2.0)
30
+ jekyll-watch (~> 2.0)
31
+ kramdown (~> 2.3)
32
+ kramdown-parser-gfm (~> 1.0)
33
+ liquid (~> 4.0)
34
+ mercenary (~> 0.4.0)
35
+ pathutil (~> 0.9)
36
+ rouge (~> 3.0)
37
+ safe_yaml (~> 1.0)
38
+ terminal-table (~> 2.0)
39
+ jekyll-sass-converter (2.2.0)
40
+ sassc (> 2.0.1, < 3.0)
41
+ jekyll-watch (2.2.1)
42
+ listen (~> 3.0)
43
+ kramdown (2.4.0)
44
+ rexml
45
+ kramdown-parser-gfm (1.1.0)
46
+ kramdown (~> 2.0)
47
+ liquid (4.0.3)
48
+ listen (3.7.1)
49
+ rb-fsevent (~> 0.10, >= 0.10.3)
50
+ rb-inotify (~> 0.9, >= 0.9.10)
51
+ mercenary (0.4.0)
52
+ pathutil (0.16.2)
53
+ forwardable-extended (~> 2.6)
54
+ power_assert (1.1.7)
55
+ public_suffix (5.0.0)
56
+ rake (13.0.6)
57
+ rb-fsevent (0.11.2)
58
+ rb-inotify (0.10.1)
59
+ ffi (~> 1.0)
60
+ rexml (3.2.5)
61
+ rouge (3.30.0)
62
+ rspec (3.11.0)
63
+ rspec-core (~> 3.11.0)
64
+ rspec-expectations (~> 3.11.0)
65
+ rspec-mocks (~> 3.11.0)
66
+ rspec-core (3.11.0)
67
+ rspec-support (~> 3.11.0)
68
+ rspec-expectations (3.11.1)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.11.0)
71
+ rspec-mocks (3.11.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.11.0)
74
+ rspec-power_assert (1.1.0)
75
+ power_assert (~> 1.1.0)
76
+ rspec (>= 2.14)
77
+ rspec-support (3.11.1)
78
+ safe_yaml (1.0.5)
79
+ sassc (2.4.0)
80
+ ffi (~> 1.9)
81
+ terminal-table (2.0.0)
82
+ unicode-display_width (~> 1.1, >= 1.1.1)
83
+ unicode-display_width (1.8.0)
84
+
85
+ PLATFORMS
86
+ arm64-darwin-21
87
+ x86_64-darwin-20
88
+ x86_64-linux
89
+
90
+ DEPENDENCIES
91
+ jekyll-breadcrumbs-tag!
92
+ rake (~> 13.0)
93
+ rspec
94
+ rspec-power_assert
95
+
96
+ BUNDLED WITH
97
+ 2.3.14
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Jekyll Breadcrumbs Tag
2
+
3
+ Breadcrumbs tag for Jekyll.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+
11
+ group :jekyll_plugins do
12
+ gem "jekyll-breadcrumbs-tag"
13
+ end
14
+ ```
15
+
16
+ ```
17
+ bundle
18
+ ```
19
+
20
+ ```yml
21
+ # _config.yml
22
+ plugins: [jekyll-breadcrumbs-tag]
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ `_config.yaml`:
28
+
29
+ ```yaml
30
+ breadcrumbs:
31
+ -
32
+ name: top
33
+ link: /
34
+ text: Top Page
35
+ -
36
+ name: about
37
+ link: /about
38
+ text: About Page
39
+ parent: top
40
+ ```
41
+
42
+
43
+ ```html
44
+ <%= breadcrumbs about %>
45
+ ```
46
+
47
+ Custom template `_includes/breadcrumbs.html`:
48
+
49
+ ```html
50
+ {% for breadcrumb in breadcrumbs %}
51
+ {% if forloop.first == false %}&nbsp;>&nbsp;{% endif %}<a href="{{ breadcrumb.link }}">{{ breadcrumb.text }}</a>
52
+ {% endfor %}
53
+ ```
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "breadcrumbs/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "jekyll-breadcrumbs-tag"
9
+ spec.version = Breadcrumbs::VERSION
10
+ spec.authors = [""]
11
+ spec.email = [""]
12
+
13
+ spec.summary = "Breadcrumbs tag for Jekyll"
14
+ spec.description = "Breadcrumbs tag for Jekyll"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["source_code_uri"] = "https://github.com/colorfulcompany/jekyll-breadcrumbs-tag"
18
+
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject do |f|
21
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
22
+ end
23
+ end
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_runtime_dependency "jekyll"
28
+ end
@@ -0,0 +1,20 @@
1
+ module Breadcrumbs
2
+ class List
3
+ def initialize(all)
4
+ @all = all
5
+ end
6
+
7
+ def to_a(name)
8
+ list = []
9
+ list << @all.find { |b| b["name"] == name }
10
+ loop do
11
+ if list.first["parent"]
12
+ list.prepend(@all.find { |b| b["name"] === list.first["parent"] })
13
+ else
14
+ break
15
+ end
16
+ end
17
+ list
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ require "jekyll"
2
+ require_relative "./template"
3
+ require_relative "./list"
4
+
5
+ module Breadcrumbs
6
+ class Tag < Liquid::Tag
7
+ def initialize(_, name, _)
8
+ @name = name.strip
9
+ end
10
+
11
+ def render(context)
12
+ root = context.registers[:site].config["source"]
13
+ template = Breadcrumbs::Template.new(root).load
14
+ Liquid::Template.parse(template).render(
15
+ {
16
+ "breadcrumbs" => Breadcrumbs::List.new(context.registers[:site].config["breadcrumbs"]).to_a(@name)
17
+ }
18
+ )
19
+ end
20
+
21
+ Liquid::Template.register_tag "breadcrumbs", self
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ {% for breadcrumb in breadcrumbs %}{% if forloop.first == false %}&nbsp;>&nbsp;{% endif %}<a href="{{ breadcrumb.link }}">{{ breadcrumb.text }}</a>{% endfor %}
@@ -0,0 +1,16 @@
1
+ module Breadcrumbs
2
+ class Template
3
+ def initialize(root)
4
+ @root = root
5
+ end
6
+
7
+ def load
8
+ custom = File.join(@root, "_includes", "breadcrumbs.html")
9
+ if File.exist?(custom)
10
+ File.read(custom)
11
+ else
12
+ File.read(File.join(__dir__, "template.html"))
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Breadcrumbs
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1 @@
1
+ require "jekyll_breadcrumbs_tag"
@@ -0,0 +1,2 @@
1
+ require "breadcrumbs/version"
2
+ require "breadcrumbs/tag"
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-breadcrumbs-tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ''
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-29 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Breadcrumbs tag for Jekyll
28
+ email:
29
+ - ''
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".ruby-version"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - Rakefile
40
+ - jekyll-breadcrumbs-tag.gemspec
41
+ - lib/breadcrumbs/list.rb
42
+ - lib/breadcrumbs/tag.rb
43
+ - lib/breadcrumbs/template.html
44
+ - lib/breadcrumbs/template.rb
45
+ - lib/breadcrumbs/version.rb
46
+ - lib/jekyll-breadcrumbs-tag.rb
47
+ - lib/jekyll_breadcrumbs_tag.rb
48
+ homepage:
49
+ licenses: []
50
+ metadata:
51
+ source_code_uri: https://github.com/colorfulcompany/jekyll-breadcrumbs-tag
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.7.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.3.7
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Breadcrumbs tag for Jekyll
71
+ test_files: []