Skip to content

Commit a3e309e

Browse files
kieran-macklevsoch
andauthored
Added support for multiple first-level sidebar headings (#46)
* Added support for multiple first-level sidebar headings * version bump and adding example of second top level menu Signed-off-by: vsoch <[email protected]> Co-authored-by: vsoch <[email protected]>
1 parent b5f32a1 commit a3e309e

File tree

5 files changed

+60
-31
lines changed

5 files changed

+60
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Critical items to know are:
1414
- changed behaviour
1515

1616
## [master](https://github.com/vsoch/docsy-jekyll/tree/master)
17+
- sidebar fix to support multiple top level menus (0.0.23)
1718
- added support for github_branch (default 'master') in config (0.0.22)
1819
- adding support in footer to icon and link to linkedin url (0.0.21)
1920
- updating repository with copyright notice, google analytics bug fix (0.0.2)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.22
1+
0.0.23

_data/toc.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
url: "docs/getting-started#development"
1111
- title: Customization
1212
url: "docs/getting-started#customization"
13-
- title: "Extras"
14-
url: "docs/extras"
15-
children:
16-
- title: Quizzes
17-
url: "docs/extras/example-quiz"
18-
- title: Tags Page
19-
url: "tags"
2013
- title: "About"
2114
url: "about"
2215
- title: "News"
2316
url: "news"
17+
- title: "Extras"
18+
url: "docs/extras"
19+
links:
20+
- title: Quizzes
21+
url: "docs/extras/example-quiz"
22+
- title: Tags Page
23+
url: "tags"

_docs/extras/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ but can further enhance your documentation pages. Currently, we have support
1212
for adding interactive quizzes.
1313

1414
- [Quizzes](example-quiz)
15+
- [Tags]({{ site.baseurl }}/tags/)
1516

16-
17-
Would you like to see another question type, or another kind of extra? Please
18-
[open an issue])({{ site.repo }}/issues/new).
17+
Would you like to see another question type, or another kind of extra? Please [open an issue]({{ site.repo }}/issues/new).

_includes/sidebar.html

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,54 @@
1-
<div id="td-sidebar-menu" class="td-sidebar__inner">
1+
<div id="td-sidebar-menu" class="td-sidebar__inner">
2+
23
<form class="td-sidebar__search d-flex align-items-center">
3-
<input type="search" class="form-control td-search-input" placeholder="&#xf002 Search this site…" aria-label="Search this site…" autocomplete="off">
4-
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
5-
</button>
4+
<input type="search" class="form-control td-search-input" placeholder="&#xf002 Search this site…" aria-label="Search this site…" autocomplete="off">
5+
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
6+
</button>
67
</form>
8+
79
<nav class="collapse td-sidebar-nav pt-2 pl-4" id="td-section-nav">
8-
{% for section in site.data.toc %}<ul class="td-sidebar-nav__section pr-md-3">
9-
{% capture sectionUrl %}{{ section.url | replace: "/", "" }}{% endcapture %}
10-
{% capture pageUrl %}{{ page.url | replace: "/", "" }}{% endcapture %}
11-
<li class="td-sidebar-nav__section-title">
12-
<a href="{% if section.url %}{{ site.baseurl }}/{{ section.url }}{% else %}{{ section.external_url }}{% endif %}" class="align-left pl-0 pr-2 active td-sidebar-link td-sidebar-link__section">{{ section.title }}</a>
13-
</li>{% if section.links %}<ul>
14-
<li class="collapse show" id="{{ section.title | slugify }}">
15-
<ul class="td-sidebar-nav__section pr-md-3">{% for entry in section.links %}
16-
<li class="td-sidebar-nav__section-title">
17-
<a href="{% if entry.url %}{{ site.baseurl }}/{{ entry.url }}{% else %}{{ entry.external_url }}{% endif %}" class="align-left pl-0 pr-2 td-sidebar-link td-sidebar-link__section">{{ entry.title }}</a>
18-
</li>
19-
{% if page.url contains entry.url or pageUrl == sectionUrl %}
20-
<ul><li class="collapse show" id="{{ child.title | slugify }}">{% if entry.children %}
21-
{% for child in entry.children %}<a class="td-sidebar-link td-sidebar-link__page " id="m-{{ section.title | slugify }}-{{ entry.title | slugify }}-{{ child.title | slugify }}" href="{% if child.url %}{{ site.baseurl }}/{{ child.url }}{% else %}{{ child.external_url }}{% endif %}">{{ child.title }}</a>{% endfor %}
22-
{% endif %}</li></ul>{% endif %}{% endfor %}
23-
</ul>{% endif %}{% endfor %}
10+
{% for section in site.data.toc %}
11+
<ul class="td-sidebar-nav__section pr-md-3">
12+
{% capture sectionUrl %}
13+
{{ section.url | replace: "/", "" }}
14+
{% endcapture %}
15+
{% capture pageUrl %}
16+
{{ page.url | replace: "/", "" }}
17+
{% endcapture %}
18+
19+
<li class="td-sidebar-nav__section-title">
20+
<a href="{% if section.url %}{{ site.baseurl }}/{{ section.url }}{% else %}{{ section.external_url }}{% endif %}" class="align-left pl-0 pr-2 active td-sidebar-link td-sidebar-link__section">{{ section.title }}</a>
21+
</li>
22+
{% if section.links %}
23+
<ul>
24+
<li class="collapse show" id="{{ section.title | slugify }}">
25+
<ul class="td-sidebar-nav__section pr-md-3">
26+
{% for entry in section.links %}
27+
<li class="td-sidebar-nav__section-title">
28+
<a href="{% if entry.url %}
29+
{{ site.baseurl }}/{{ entry.url }}
30+
{% else %}
31+
{{ entry.external_url }}
32+
{% endif %}"
33+
class="align-left pl-0 pr-2 td-sidebar-link td-sidebar-link__section">{{ entry.title }}
34+
</a>
35+
</li>
36+
{% if page.url contains entry.url or pageUrl == sectionUrl %}
37+
<ul>
38+
<li class="collapse show" id="{{ child.title | slugify }}">
39+
{% if entry.children %}
40+
{% for child in entry.children %}
41+
<a class="td-sidebar-link td-sidebar-link__page " id="m-{{ section.title | slugify }}-{{ entry.title | slugify }}-{{ child.title | slugify }}" href="{% if child.url %}{{ site.baseurl }}/{{ child.url }}{% else %}{{ child.external_url }}{% endif %}">{{ child.title }}</a>{% endfor %}
42+
{% endif %}
43+
</li>
44+
</ul>
45+
{% endif %}
46+
{% endfor %}
47+
</ul>
48+
</li>
49+
</ul>
50+
{% endif %}
51+
</ul>
52+
{% endfor %}
2453
</nav>
2554
</div>

0 commit comments

Comments
 (0)