forked from techascent/re-frame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an extra level of rhs nav to the api docs
- Loading branch information
1 parent
e9f536b
commit 6996500
Showing
4 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!-- | ||
Copyright (c) 2016-2020 Martin Donath <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
--> | ||
|
||
<!-- Table of contents item --> | ||
<li class="md-nav__item"> | ||
<a href="{{ toc_item.url }}" class="md-nav__link"> | ||
{{ toc_item.title }} | ||
</a> | ||
|
||
<!-- Render nested item list --> | ||
|
||
<!-- | ||
CUSTOM: re-frame customization so that we can have one extra level in the | ||
rhs table of contents *only* on the apidocs page. | ||
See toc.html comment for introduction. | ||
This code works by: | ||
- incrementing the current level | ||
- checking if the current level is equal or less than the maximum depth | ||
- if true, resursively rendering this template | ||
- if false, doing nothing | ||
- decrementing the current level | ||
--> | ||
{% set re_frame_navigation_level = re_frame_navigation_level + 1 %} | ||
{% if re_frame_navigation_level <= re_frame_navigation_depth and toc_item.children %} | ||
<nav class="md-nav" aria-label="{{ toc_item.title }}"> | ||
<ul class="md-nav__list"> | ||
{% for toc_item in toc_item.children %} | ||
{% include "partials/toc-item.html" %} | ||
{% endfor %} | ||
</ul> | ||
</nav> | ||
{% endif %} | ||
{% set re_frame_navigation_level = re_frame_navigation_level - 1 %} | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!-- | ||
Copyright (c) 2016-2020 Martin Donath <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
--> | ||
|
||
{% import "partials/language.html" as lang with context %} | ||
|
||
<!-- Table of contents --> | ||
<nav class="md-nav md-nav--secondary" aria-label="{{ lang.t('toc.title') }}"> | ||
{% set toc = page.toc %} | ||
|
||
<!-- | ||
Hack: check whether the content contains a h1 headline. If it does, the | ||
top-level anchor must be skipped, since it would be redundant to the link | ||
to the current page that is located just above the anchor. Therefore we | ||
directly continue with the children of the anchor. | ||
--> | ||
{% if toc | first is defined and "\x3ch1 id=" in page.content %} | ||
{% set toc = (toc | first).children %} | ||
{% endif %} | ||
|
||
<!-- Render item list --> | ||
|
||
|
||
<!-- | ||
CUSTOM: re-frame customization so that we can have one extra level in the | ||
rhs table of contents *only* on the apidocs page. | ||
Globally in mkdocs.yml we set the table of contents extension depth to the | ||
maximum that we want to use site-wide, then filter it down depending on | ||
the markdown meta extension on a page-per-page basis. | ||
First, we need to initialize some variables that are used in toc-item.html | ||
re_frame_navigation_depth is set depending on the markdown meta extension. | ||
It is the maximum depth for the rhs table of contents. | ||
re_frame_navigation_level is the current recursive rendering depth of | ||
toc-item.html It must be both incremented and decremented on each recur. | ||
--> | ||
{% if page and page.meta and page.meta.apidocs %} | ||
{% set re_frame_navigation_depth = 2 %} | ||
{% else %} | ||
{% set re_frame_navigation_depth = 1 %} | ||
{% endif %} | ||
{% set re_frame_navigation_level = 1 %} | ||
|
||
{% if toc | first is defined %} | ||
<label class="md-nav__title" for="__toc"> | ||
<span class="md-nav__icon md-icon"> | ||
{% include ".icons/material/arrow-left.svg" %} | ||
</span> | ||
{{ lang.t("toc.title") }} | ||
</label> | ||
<ul class="md-nav__list" data-md-scrollfix> | ||
{% for toc_item in toc %} | ||
{% include "partials/toc-item.html" %} | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters