jekyll-tabs 1.2.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78ca84e5d1867d7cae701c62eae5c1d9066dfc175212fe271dad345bf85f17c4
4
- data.tar.gz: bfaa05193d4fc879493ca5fe66c70e94a1e5baf4ad304325936b329bd09a3237
3
+ metadata.gz: 49d3f07cb95500acd0b2866c35e78b2c425616708ba8460446b0337642a9ed9c
4
+ data.tar.gz: 8e237cea3292d2ad4875640b3cdd5ba6cd7704b8cdf653f8dc5d2eb4917c94da
5
5
  SHA512:
6
- metadata.gz: bfc9afab28e4defda0c26acb0a5a2f11f879618c8bb10d0c78af08b290741f8a09046215ceecf579d47c2d045349682554676b103876015588d504231e3101ce
7
- data.tar.gz: c0ecd449586ec99b82d4a1f8619ac11c51015c8e0422886dddc60621c0a41f3c8fc3e01c0e8a802353f1becf21a96e64c59040c5f5f4d4e93e467749fde974bf
6
+ metadata.gz: a49f0c568b7a74376be5b22cea12e98a042f89deadb9e73ff3da5b22aa00972be5c017ae2f13d07acb60cfec3b6ee0cbdc3f4070cc5303db5dc240122c7dfcd4
7
+ data.tar.gz: 201fa4899553cc756998ae997c160653e795eaa1b9e266308db26b2f199852bd6c90e65d6839c5f6aeb2a8d5de3bf14da79cfe0202bfca3154881ccc5fc0d921
data/docs/tabs.js CHANGED
@@ -84,7 +84,7 @@ const jekyllTabsModule = (function() {
84
84
  removeActiveClasses(tabContentElement);
85
85
 
86
86
  // Then add back active classes depending on the tab (ul element) that was clicked on.
87
- tabContentElement.querySelectorAll('ul > li')[liPositionInUl].classList.add('active');
87
+ tabContentElement.querySelectorAll('ul.tab-content > li')[liPositionInUl].classList.add('active');
88
88
  liTab.classList.add('active');
89
89
  }
90
90
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Tabs
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
data/lib/jekyll-tabs.rb CHANGED
@@ -1,6 +1,13 @@
1
1
  require 'securerandom'
2
2
  require 'erb'
3
3
 
4
+ def sanitizeName(name)
5
+ return name
6
+ .strip # remove leading and trailing whitespace
7
+ .downcase # lowercase
8
+ .gsub(/[^0-9a-z]/, '-') # replace all non alphabjetical or non numerical characetrs by a dash
9
+ end
10
+
4
11
  module Jekyll
5
12
  module Tabs
6
13
  class TabsBlock < Liquid::Block
@@ -9,7 +16,8 @@ module Jekyll
9
16
  if markup == ''
10
17
  raise SyntaxError.new("Block #{block_name} requires 1 attribute")
11
18
  end
12
- @name = markup.strip
19
+ @name = sanitizeName(markup)
20
+
13
21
  end
14
22
 
15
23
  def render(context)
@@ -33,7 +41,7 @@ module Jekyll
33
41
  if markups.length != 2
34
42
  raise SyntaxError.new("Block #{block_name} requires 2 attributes")
35
43
  end
36
- @name = markups[0]
44
+ @name = sanitizeName(markups[0])
37
45
  @tab = markups[1]
38
46
  end
39
47
 
data/lib/template.erb CHANGED
@@ -1,6 +1,6 @@
1
1
  <ul id="<%= @name %>" class="tab" data-tab="<%= uuid %>" data-name="<%= @name %>">
2
2
  <% environment["tabs-#{@name}"].each_with_index do |(key, value), index| %>
3
- <li<%= index == 0 ? ' class="active"' : ''%> id="<%= key.dup.downcase.gsub!(/[^0-9A-Za-z]/, '-').chomp('-') %>">
3
+ <li<%= index == 0 ? ' class="active"' : ''%> id="<%= @name + '-' + key.dup.strip.downcase.gsub(/[^0-9a-z]/, '-') %>">
4
4
  <a href="#"><%= key %></a>
5
5
  </li>
6
6
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-tabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nejc Zdovc
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-15 00:00:00.000000000 Z
12
+ date: 2023-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll