Skip to content

Make specmatic.yaml the default tab in all configuration examples #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions _plugins/_jekyll-tabs-specmatic.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<div class="tab-wrapper">
<ul class="tab">
<% environment["tabs-#{@name}"].each_with_index do |(key, value), index| %>
<% sorted_tabs = sort_tabs_with_prioritized_tab(environment["tabs-#{@name}"], 'specmatic.yaml') %>
<% sorted_tabs.each_with_index do |(key, value), index| %>
<li <%= index == 0 ? ' class="active"' : ''%>>
<button class="tab-click" data-tab-content-selector="<%= uuid %>-<%= @name %>-<%= key %>"><%= key %></button>
</li>
<% end %>
</ul>

<ul class="tab-content">
<% environment["tabs-#{@name}"].each_with_index do |(key, value), index| %>
<% sorted_tabs.each_with_index do |(key, value), index| %>
<li <%= index == 0 ? ' class="active"' : ''%> data-tab-content-id="<%= uuid %>-<%= @name %>-<%= key %>"><%= value %></li>
<% end %>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions _plugins/jekyll-tabs-specmatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def sanitizeName(name)
.gsub(/[^0-9a-z]/, '-') # replace all non alphabjetical or non numerical characetrs by a dash
end

def sort_tabs_with_prioritized_tab(tabs, prioritized_tab_name)
tabs.sort_by { |key, value| key.include?(prioritized_tab_name) ? 0 : 1 }
end

module Jekyll
module Tabs
class TabsBlock < Liquid::Block
Expand Down