swedbank-pay-design-guide-jekyll-theme 1.5.1.pre.article.pre.no.pre.main0001
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 +7 -0
- data/LICENSE +201 -0
- data/README.md +103 -0
- data/_assets/css/pygments-autumn.css +66 -0
- data/_assets/scss/card.scss +170 -0
- data/_assets/scss/code-view.scss +13 -0
- data/_assets/scss/colors.scss +19 -0
- data/_assets/scss/fonts.scss +2 -0
- data/_assets/scss/front-page.scss +312 -0
- data/_assets/scss/heading.scss +79 -0
- data/_assets/scss/paragraph-highlight.scss +8 -0
- data/_assets/scss/sidebar.scss +72 -0
- data/_assets/scss/swedbank-pay-design-guide-theme.scss +290 -0
- data/_assets/scss/title-header.scss +39 -0
- data/_assets/scss/variables.scss +1 -0
- data/_includes/alert.html +34 -0
- data/_includes/anchor_headings.html +100 -0
- data/_includes/apple-mobile-headers.html +6 -0
- data/_includes/apple-touch-icon.html +4 -0
- data/_includes/apple-touch-icons.md +9 -0
- data/_includes/apple-touch-startup-image.html +23 -0
- data/_includes/apple-touch-startup-images.md +31 -0
- data/_includes/card-horizontal-list.html +33 -0
- data/_includes/card-list.html +28 -0
- data/_includes/card.html +73 -0
- data/_includes/front-page.html +255 -0
- data/_includes/google_analytics.html +9 -0
- data/_includes/img/merchants/logo-coop.svg +3 -0
- data/_includes/img/merchants/logo-elkjop.svg +23 -0
- data/_includes/img/merchants/logo-ica.svg +57 -0
- data/_includes/img/merchants/logo-schibsted.svg +30 -0
- data/_includes/img/merchants/logo-skanetrafiken.svg +5 -0
- data/_includes/img/merchants/logo-svenskaspel.svg +23 -0
- data/_includes/img/merchants/logo-synsam.svg +12 -0
- data/_includes/img/modules/logo-episerver.svg +15 -0
- data/_includes/img/modules/logo-magento2.svg +5 -0
- data/_includes/img/modules/logo-woocommerce.svg +16 -0
- data/_includes/img/sdks/logo-android.svg +3 -0
- data/_includes/img/sdks/logo-ios.svg +3 -0
- data/_includes/img/sdks/logo-net.svg +15 -0
- data/_includes/img/sdks/logo-nodejs.svg +3 -0
- data/_includes/img/sdks/logo-php.svg +5 -0
- data/_includes/img/sdks/logo-swift.svg +10 -0
- data/_includes/iterator.html +18 -0
- data/_includes/jumbotron.html +6 -0
- data/_includes/paragraph-highlight.html +7 -0
- data/_includes/release_notes.html +29 -0
- data/_includes/sidebar.html +116 -0
- data/_includes/toc.html +100 -0
- data/_layouts/default.html +145 -0
- data/_plugins/jekyll_asset_pipeline.rb +19 -0
- data/_plugins/sidebar.rb +211 -0
- data/assets/img/demoshop-mobile.svg +18 -0
- data/assets/img/demoshop-mobile2.svg +23 -0
- data/assets/img/demoshop-web.svg +31 -0
- data/assets/img/demoshop.svg +27 -0
- data/assets/img/external-url.svg +1 -0
- data/assets/js/mermaid.min.js +19 -0
- data/assets/js/swedbank-pay-design-guide-theme.js +136 -0
- data/assets/tipuesearch/search.png +0 -0
- data/assets/tipuesearch/tipuesearch.min.js +179 -0
- data/assets/tipuesearch/tipuesearch_content.js +83 -0
- data/assets/tipuesearch/tipuesearch_set.js +80 -0
- metadata +293 -0
data/_includes/toc.html
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
{% capture tocWorkspace %}
|
2
|
+
{% comment %}
|
3
|
+
Version 1.0.8
|
4
|
+
https://github.com/allejo/jekyll-toc
|
5
|
+
|
6
|
+
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %}
|
10
|
+
|
11
|
+
Parameters:
|
12
|
+
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
|
13
|
+
|
14
|
+
Optional Parameters:
|
15
|
+
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
|
16
|
+
* class (string) : '' - a CSS class assigned to the TOC
|
17
|
+
* id (string) : '' - an ID to assigned to the TOC
|
18
|
+
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
|
19
|
+
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
|
20
|
+
* ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
|
21
|
+
* item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is
|
22
|
+
the current heading level
|
23
|
+
* baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
|
24
|
+
* anchor_class (string) : '' - add custom class(es) for each anchor element
|
25
|
+
|
26
|
+
Output:
|
27
|
+
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only
|
28
|
+
generate the table of contents and will NOT output the markdown given to it
|
29
|
+
{% endcomment %}
|
30
|
+
|
31
|
+
{% capture my_toc %}{% endcapture %}
|
32
|
+
{% assign orderedList = include.ordered | default: false %}
|
33
|
+
{% assign minHeader = include.h_min | default: 1 %}
|
34
|
+
{% assign maxHeader = include.h_max | default: 6 %}
|
35
|
+
{% assign nodes = include.html | split: '<h' %}
|
36
|
+
{% assign firstHeader = true %}
|
37
|
+
|
38
|
+
{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}
|
39
|
+
|
40
|
+
{{ include.ordered }}
|
41
|
+
|
42
|
+
{% for node in nodes %}
|
43
|
+
{% if node == "" %}
|
44
|
+
{% continue %}
|
45
|
+
{% endif %}
|
46
|
+
|
47
|
+
{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %}
|
48
|
+
|
49
|
+
{% if headerLevel < minHeader or headerLevel > maxHeader %}
|
50
|
+
{% continue %}
|
51
|
+
{% endif %}
|
52
|
+
|
53
|
+
{% if firstHeader %}
|
54
|
+
{% assign firstHeader = false %}
|
55
|
+
{% assign minHeader = headerLevel %}
|
56
|
+
{% endif %}
|
57
|
+
|
58
|
+
{% assign indentAmount = headerLevel | minus: minHeader %}
|
59
|
+
{% assign _workspace = node | split: '</h' %}
|
60
|
+
|
61
|
+
{% assign _idWorkspace = _workspace[0] | split: 'id="' %}
|
62
|
+
{% assign _idWorkspace = _idWorkspace[1] | split: '"' %}
|
63
|
+
{% assign html_id = _idWorkspace[0] %}
|
64
|
+
|
65
|
+
{% assign _classWorkspace = _workspace[0] | split: 'class="' %}
|
66
|
+
{% assign _classWorkspace = _classWorkspace[1] | split: '"' %}
|
67
|
+
{% assign html_class = _classWorkspace[0] %}
|
68
|
+
|
69
|
+
{% if html_class contains "no_toc" %}
|
70
|
+
{% continue %}
|
71
|
+
{% endif %}
|
72
|
+
|
73
|
+
{% capture _hAttrToStrip %}{{ _workspace[0] | split: '>' | first }}>{% endcapture %}
|
74
|
+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
|
75
|
+
|
76
|
+
{% assign space = '' %}
|
77
|
+
{% for i in (1..indentAmount) %}
|
78
|
+
{% assign space = space | prepend: ' ' %}
|
79
|
+
{% endfor %}
|
80
|
+
|
81
|
+
{% unless include.item_class == blank %}
|
82
|
+
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
|
83
|
+
{% endunless %}
|
84
|
+
|
85
|
+
{% capture heading_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
|
86
|
+
{% capture my_toc %}{{ my_toc }}
|
87
|
+
{{ space }}{{ listModifier }} {{ listItemClass }}
|
88
|
+
[{{ heading_body | replace: "|", "\|" }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
|
89
|
+
{% endfor %}
|
90
|
+
|
91
|
+
{% if include.class %}
|
92
|
+
{% capture my_toc %}{:.{{ include.class }}}
|
93
|
+
{{ my_toc | lstrip }}{% endcapture %}
|
94
|
+
{% endif %}
|
95
|
+
|
96
|
+
{% if include.id %}
|
97
|
+
{% capture my_toc %}{: #{{ include.id }}}
|
98
|
+
{{ my_toc | lstrip }}{% endcapture %}
|
99
|
+
{% endif %}
|
100
|
+
{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }}
|
@@ -0,0 +1,145 @@
|
|
1
|
+
{%- assign title = page.title | default: "PayEx Design Guide theme for Jekyll" -%}
|
2
|
+
{%- assign front_page = page.front_page | default: false -%}
|
3
|
+
{%- assign description = page.opengraph.description | default: site.opengraph.description -%}
|
4
|
+
{%- assign image = page.opengraph.image | default: site.opengraph.image -%}
|
5
|
+
{%- assign github_branch = site.github.branch | default : "develop" -%}
|
6
|
+
{%- assign design_guide_base_url = site.design_guide.base_url | default: 'https://design.swedbankpay.com' -%}
|
7
|
+
{%- assign design_guide_version = site.design_guide.version | default: '4.7.0' -%}
|
8
|
+
{%- assign design_guide_url = design_guide_base_url | append: '/v/' | append: design_guide_version -%}
|
9
|
+
{%- if page.sidebar.navigation == nil -%}
|
10
|
+
{%- unless page.name contains "index" -%}
|
11
|
+
{%- assign dirname = page.dir | split: "/" | last | remove: "/" | capitalize -%}
|
12
|
+
{%- unless dirname == "" -%}
|
13
|
+
{%- assign title = dirname | append: " – " | append: title -%}
|
14
|
+
{%- endunless -%}
|
15
|
+
{%- endunless -%}
|
16
|
+
{%- endif -%}
|
17
|
+
<!DOCTYPE html>
|
18
|
+
<html lang="{{ site.lang | default: "en-US" }}">
|
19
|
+
|
20
|
+
<head>
|
21
|
+
<meta charset="utf-8" />
|
22
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
23
|
+
<meta name="mobile-web-app-capable" content="yes">
|
24
|
+
<meta name="theme-color" content="#000">
|
25
|
+
<meta name="application-name" content="{{ page.title }}">
|
26
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
27
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
28
|
+
<meta name="apple-mobile-web-app-title"
|
29
|
+
content="{{ page.title | default: 'PayEx Design Guide theme for Jekyll' }}">
|
30
|
+
<meta name="msapplication-TileColor" content="#000">
|
31
|
+
<meta name="msapplication-TileImage" content="{{ design_guide_version_url }}/icons/mstile-144x144.png">
|
32
|
+
<meta property="og:type" value="website" />
|
33
|
+
{%- if page.url != nil %}
|
34
|
+
<meta property="og:url" value="{{ page.url | absolute_url }}" />{% endif %}
|
35
|
+
<meta property="og:title" value="{{ title }}" />
|
36
|
+
<meta name="title" content="{{ title }}" />
|
37
|
+
{%- if description != nil %}
|
38
|
+
<meta property="og:description" value="{{ description }}" />
|
39
|
+
<meta name="description" content="{{ description }}" />{% endif %}
|
40
|
+
{%- if image != nil %}
|
41
|
+
<meta property="og:image" value="{{ image }}" />{% endif %}
|
42
|
+
<title>{{ title }}</title>
|
43
|
+
<link rel="stylesheet" href="{{ design_guide_url }}/styles/dg-style.css" />
|
44
|
+
{% css_asset_tag theme %}
|
45
|
+
- /_assets/scss/card.scss
|
46
|
+
- /_assets/scss/code-view.scss
|
47
|
+
- /_assets/scss/colors.scss
|
48
|
+
- /_assets/scss/fonts.scss
|
49
|
+
- /_assets/scss/front-page.scss
|
50
|
+
- /_assets/scss/heading.scss
|
51
|
+
- /_assets/scss/paragraph-highlight.scss
|
52
|
+
- /_assets/scss/sidebar.scss
|
53
|
+
- /_assets/scss/swedbank-pay-design-guide-theme.scss
|
54
|
+
- /_assets/scss/title-header.scss
|
55
|
+
- /_assets/scss/variables.scss
|
56
|
+
- /_assets/css/pygments-autumn.css
|
57
|
+
{% endcss_asset_tag %}
|
58
|
+
<link rel="shortcut icon" href="{{ design_guide_url }}/icons/favicon.ico">
|
59
|
+
<link rel="icon" type="image/png" sizes="16x16" href="{{ design_guide_url }}/icons/favicon-16x16.png">
|
60
|
+
<link rel="icon" type="image/png" sizes="32x32" href="{{ design_guide_url }}/icons/favicon-32x32.png">
|
61
|
+
<link rel="icon" type="image/png" sizes="228x228" href="{{ design_guide_url }}/icons/coast-228x228.png">
|
62
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons+Outlined" rel="stylesheet">
|
63
|
+
{%- include apple-mobile-headers.html design_guide_url=design_guide_url -%}
|
64
|
+
<script src="{{ '/assets/js/mermaid.min.js' | relative_url }}"></script>
|
65
|
+
{%- if site.search.enabled == true %}
|
66
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
67
|
+
<script src="{{ "/assets/tipuesearch/tipuesearch_content.js" | relative_url }}"></script>
|
68
|
+
<script src="{{ "/assets/tipuesearch/tipuesearch_set.js" | relative_url }}"></script>
|
69
|
+
<script src="{{ "/assets/tipuesearch/tipuesearch.min.js" | relative_url }}"></script>
|
70
|
+
{%- endif %}
|
71
|
+
</head>
|
72
|
+
|
73
|
+
<body>
|
74
|
+
<div id="designguide">
|
75
|
+
<div class="documentation">
|
76
|
+
<div class="row">
|
77
|
+
<div class="col-xxl-2 col-lg-3 pr-0">
|
78
|
+
<div class="sidebar dg-sidebar">
|
79
|
+
<nav class="sidebar-nav">
|
80
|
+
<a href="/" class="sidebar-header">
|
81
|
+
<img src="{{ design_guide_url }}/img/swedbankpay-logo-v.svg"
|
82
|
+
alt="Swedbank Pay vertical logo" />
|
83
|
+
<div class="sidebar-header-text">
|
84
|
+
<span>{</span>developer portal<span>}</span>
|
85
|
+
</div>
|
86
|
+
</a>
|
87
|
+
|
88
|
+
<ul id="dx-sidebar-main-nav-ul" class="main-nav-ul">
|
89
|
+
</ul>
|
90
|
+
</nav>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<main class="doc-view col-xxl-10 col-lg-9">
|
95
|
+
{% if front_page != true %}
|
96
|
+
{% assign title_lead = title | split: '–' | first %}
|
97
|
+
{% assign title_main = title | split: '–' | last %}
|
98
|
+
{% assign description = page.description %}
|
99
|
+
{% assign estimated_read = page.estimated_read %}
|
100
|
+
<div class="title-header">
|
101
|
+
<div class="title-header-container
|
102
|
+
{% if page.card_overview%} max-width-card-overview
|
103
|
+
{% else %} max-width
|
104
|
+
{% endif %}">
|
105
|
+
{% if title_lead != title_main %}
|
106
|
+
<h4>{{ title_lead }}</h4>
|
107
|
+
{% endif %}
|
108
|
+
<h1>{{ title_main }}</h1>
|
109
|
+
{% if estimated_read %}
|
110
|
+
<div class="title-header-estimated-read">
|
111
|
+
<i class="material-icons">schedule</i>
|
112
|
+
{{ estimated_read }} min read
|
113
|
+
</div>
|
114
|
+
{% endif %}
|
115
|
+
{% if description %}
|
116
|
+
<p>{{ description | markdownify }}</p>
|
117
|
+
{% endif %}
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
{% endif %}
|
121
|
+
<div class="doc-container{% if front_page == true %} no-padding
|
122
|
+
{% elsif page.card_overview%} normal-padding max-width-card-overview
|
123
|
+
{% else %} normal-padding max-width
|
124
|
+
{% endif %}">
|
125
|
+
<article>
|
126
|
+
{% include anchor_headings.html html=content anchorClass='header-anchor' %}
|
127
|
+
</article>
|
128
|
+
</div>
|
129
|
+
</main>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<footer class="page-footer">
|
134
|
+
<p class="page-footer-rights">© Swedbank Pay</p>
|
135
|
+
</footer>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<script src="{{ design_guide_url }}/scripts/dg.js"></script>
|
139
|
+
<script src="{{ '/assets/js/swedbank-pay-design-guide-theme.js' | relative_url }}"></script>
|
140
|
+
{%- if site.google_analytics.tracking_id %}
|
141
|
+
{% include google_analytics.html %}
|
142
|
+
{%- endif %}
|
143
|
+
</body>
|
144
|
+
|
145
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll_asset_pipeline'
|
4
|
+
|
5
|
+
module JekyllAssetPipeline
|
6
|
+
# Converts .scss files to CSS.
|
7
|
+
class SassConverter < JekyllAssetPipeline::Converter
|
8
|
+
require 'sass'
|
9
|
+
|
10
|
+
def self.filetype
|
11
|
+
'.scss'
|
12
|
+
end
|
13
|
+
|
14
|
+
def convert
|
15
|
+
dir = File.join(__dir__, '..', '_assets', 'scss')
|
16
|
+
Sass::Engine.new(@content, syntax: :scss, load_paths: [dir]).render
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/_plugins/sidebar.rb
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'jekyll'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
class Sidebar
|
9
|
+
attr_accessor :hash_pre_render
|
10
|
+
attr_accessor :filename_with_headers
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@hash_pre_render = {}
|
14
|
+
@filename_with_headers = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def pre_render(page)
|
18
|
+
menu_order = page['menu-order'].nil? ? 0 : page['menu-order']
|
19
|
+
hide_from_sidebar = page['hide_from_sidebar'].nil? ? false : page['hide_from_sidebar']
|
20
|
+
url = page['url'].gsub('index.html', '').gsub('.html', '')
|
21
|
+
@hash_pre_render[url] = {
|
22
|
+
title: page['title'],
|
23
|
+
url: page['url'].gsub('.html', ''),
|
24
|
+
name: page['name'],
|
25
|
+
menu_order: menu_order,
|
26
|
+
hide_from_sidebar: hide_from_sidebar
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def post_write(site)
|
31
|
+
files = []
|
32
|
+
Dir.glob("#{site.config['destination']}/**/*.html") do |filename|
|
33
|
+
doc = File.open(filename) { |f| Nokogiri::HTML(f) }
|
34
|
+
files.push(doc)
|
35
|
+
|
36
|
+
headers = []
|
37
|
+
doc.xpath('//h2 ').each do |header|
|
38
|
+
next unless header['id']
|
39
|
+
|
40
|
+
child = header.last_element_child
|
41
|
+
header = {
|
42
|
+
id: header['id'],
|
43
|
+
title: header.content.strip,
|
44
|
+
hash: (child['href']).to_s
|
45
|
+
}
|
46
|
+
headers.push(header)
|
47
|
+
end
|
48
|
+
sanitized_filename = sanitize_filename(filename)
|
49
|
+
@filename_with_headers[sanitized_filename] = { headers: headers }
|
50
|
+
end
|
51
|
+
|
52
|
+
Dir.glob("#{site.config['destination']}/**/*.html") do |filename|
|
53
|
+
sanitized_filename = sanitize_filename(filename)
|
54
|
+
sidebar = render(sanitized_filename)
|
55
|
+
file = File.open(filename) { |f| Nokogiri::HTML(f) }
|
56
|
+
file.xpath('//*[@id="dx-sidebar-main-nav-ul"]').each do |location|
|
57
|
+
location.inner_html = sidebar
|
58
|
+
end
|
59
|
+
File.open(filename, 'w') { |f| f.write(file.to_html(encoding: 'UTF-8')) }
|
60
|
+
end
|
61
|
+
|
62
|
+
# File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar) }
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def sanitize_filename(filename)
|
68
|
+
sanitized_filename = filename.match(/(?m)(?<=\b_site).*$/)[0]
|
69
|
+
sanitized_filename = sanitized_filename.gsub('index.html', '')
|
70
|
+
sanitized_filename.gsub('.html', '')
|
71
|
+
end
|
72
|
+
|
73
|
+
def generateSubgroup(filename, key, value, all_subgroups, level)
|
74
|
+
title = value[:title].split('–').last
|
75
|
+
subsubgroup_list = all_subgroups.select do |subsubgroup_key, _subsubgroup_value|
|
76
|
+
subsubgroup_key.include? key and subsubgroup_key != key and \
|
77
|
+
key.split('/').length > level
|
78
|
+
end
|
79
|
+
|
80
|
+
subgroup = ''
|
81
|
+
has_subgroups = !all_subgroups.empty?
|
82
|
+
if value[:headers].any? || !subsubgroup_list.empty?
|
83
|
+
if has_subgroups
|
84
|
+
url = value[:url]
|
85
|
+
active = active?(filename, url, true)
|
86
|
+
# puts "#{url}, #{filename}, #{key}" if active
|
87
|
+
item_class = active || (url.split('/').length > level && filename.start_with?(url)) ? 'nav-subgroup active' : 'nav-subgroup'
|
88
|
+
subgroup << "<li class=\"#{item_class}\">"
|
89
|
+
subgroup << "<div class=\"nav-subgroup-heading\"><i class=\"material-icons\">arrow_right</i><a href=\"#{url}\">#{title}</a></div>"
|
90
|
+
subgroup << '<ul class="nav-ul">'
|
91
|
+
|
92
|
+
if subsubgroup_list.empty?
|
93
|
+
value[:headers].each do |header|
|
94
|
+
subgroup << "<li class=\"nav-leaf\"><a href=\"#{value[:url]}#{header[:hash]}\">#{header[:title]}</a></li>"
|
95
|
+
end
|
96
|
+
else
|
97
|
+
subgroup_leaf_class = active ? 'nav-leaf nav-subgroup-leaf active' : 'nav-leaf nav-subgroup-leaf'
|
98
|
+
subgroup << "<li class=\"#{subgroup_leaf_class}\"><a href=\"#{value[:url]}\">#{title} overview</a></li>"
|
99
|
+
|
100
|
+
subsubgroup_list.each do |subsubgroup_key, subsubgroup_value|
|
101
|
+
subgroup << generateSubgroup(filename, subsubgroup_key, subsubgroup_value, subsubgroup_list, 3)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
subgroup << '</ul>'
|
106
|
+
subgroup << '</li>'
|
107
|
+
else
|
108
|
+
value[:headers].each do |header|
|
109
|
+
subgroup << "<li class=\"nav-leaf\"><a href=\"#{value[:url]}#{header[:hash]}\">#{header[:title]}</a></li>"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
else
|
113
|
+
subgroup << if has_subgroups
|
114
|
+
"<li class=\"nav-leaf nav-subgroup-leaf\"><a href=\"#{value[:url]}\">#{title}</a></li>"
|
115
|
+
else
|
116
|
+
"<li class=\"nav-leaf\"><a href=\"#{value[:url]}\">#{title}</a></li>"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
subgroup
|
121
|
+
end
|
122
|
+
|
123
|
+
def render(filename)
|
124
|
+
sidebar = ''
|
125
|
+
|
126
|
+
merged = merge(@hash_pre_render, @filename_with_headers).sort_by { |_key, value| value[:menu_order] }
|
127
|
+
merged.select { |key, _value| key.split('/').length <= 2 }.each do |key, value|
|
128
|
+
next if value[:title].nil?
|
129
|
+
next if value[:hide_from_sidebar]
|
130
|
+
|
131
|
+
subgroups = merged.select { |subgroup_key, _subgroup_value| subgroup_key.include? key and subgroup_key != key and key != '/' }
|
132
|
+
|
133
|
+
active = active?(filename, key)
|
134
|
+
# puts "#{filename}, #{key}" if active
|
135
|
+
item_class = active ? 'nav-group active' : 'nav-group'
|
136
|
+
|
137
|
+
child = "<li class=\"#{item_class}\">"
|
138
|
+
child << "<div class=\"nav-group-heading\"><i class=\"material-icons\">arrow_right</i><span>#{value[:title].split('–').first}</span></div>"
|
139
|
+
|
140
|
+
child << '<ul class="nav-ul">'
|
141
|
+
|
142
|
+
subgroup = generateSubgroup(filename, key, value, subgroups, 2)
|
143
|
+
|
144
|
+
child << subgroup
|
145
|
+
|
146
|
+
if subgroups.any?
|
147
|
+
subgroups.select { |subgroup_key, _subgroup_value| subgroup_key.split('/').length <= 3 }.each do |subgroup_key, subgroup_value|
|
148
|
+
subgroup = generateSubgroup(filename, subgroup_key, subgroup_value, subgroups, 2)
|
149
|
+
child << subgroup
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
child << '</ul>'
|
154
|
+
child << '</li>'
|
155
|
+
sidebar << child
|
156
|
+
end
|
157
|
+
|
158
|
+
File.open('_site/sidebar.html', 'w') { |f| f.write(sidebar) }
|
159
|
+
sidebar
|
160
|
+
end
|
161
|
+
|
162
|
+
def active?(filename, url, exact = false)
|
163
|
+
if filename == '/' || url == '/'
|
164
|
+
if filename == '/' && url == '/'
|
165
|
+
return true
|
166
|
+
else
|
167
|
+
return false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
exact ? filename == url : filename.start_with?(url)
|
172
|
+
end
|
173
|
+
|
174
|
+
def merge(hash1, hash2)
|
175
|
+
all_keys = hash1.keys | hash2.keys
|
176
|
+
result_hash = {}
|
177
|
+
|
178
|
+
all_keys.each do |key|
|
179
|
+
hash_value = {}
|
180
|
+
|
181
|
+
if hash1.key? key
|
182
|
+
value = hash1[key]
|
183
|
+
|
184
|
+
hash_value = value unless value.nil?
|
185
|
+
end
|
186
|
+
|
187
|
+
if hash2.key? key
|
188
|
+
value = hash2[key]
|
189
|
+
|
190
|
+
hash_value = hash_value.merge(value) unless value.nil?
|
191
|
+
end
|
192
|
+
|
193
|
+
result_hash[key] = hash_value
|
194
|
+
end
|
195
|
+
|
196
|
+
result_hash
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
sidebar = Jekyll::Sidebar.new
|
202
|
+
|
203
|
+
Jekyll::Hooks.register :site, :pre_render do |site, _payload|
|
204
|
+
site.pages.each do |page|
|
205
|
+
sidebar.pre_render page
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
210
|
+
sidebar.post_write site
|
211
|
+
end
|