-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add Next and Back Navigation Buttons to the Documentation #2864
Open
corwinjoy
wants to merge
3
commits into
duckdb:main
Choose a base branch
from
corwinjoy:navigation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,133 @@ | ||
{% if versionviewed contains 'stable' %} | ||
{%- assign menudocfile = "menu_docs_dev" -%} | ||
{% else %} | ||
{%- assign menudocfile = "menu_docs_" | append: versionviewed | replace: ".", "" -%} | ||
{% endif %} | ||
{% assign menudocfile = site.data[menudocfile].docsmenu %} | ||
|
||
|
||
<!-- Add items from menudocfile. --> | ||
{% assign docs_base_url = "/docs/" %} | ||
{% assign nav_pageList = '' %} | ||
{% for doc_entry in menudocfile %} | ||
{% if doc_entry.url %} | ||
{% assign slug_str = doc_entry.slug %} | ||
{% assign entry = ',' | append: docs_base_url | append: slug_str | append: doc_entry.url %} | ||
{% assign nav_pageList = nav_pageList | append: entry %} | ||
{%endif %} | ||
{% if doc_entry.mainfolderitems %} | ||
{% for main_entry in doc_entry.mainfolderitems %} | ||
{% if main_entry.url %} | ||
{% assign slug_str = main_entry.slug %} | ||
{% assign entry = ',' | append: docs_base_url | append: slug_str | append: '/' | append: main_entry.url %} | ||
{% assign nav_pageList = nav_pageList | append: entry %} | ||
{%endif %} | ||
{% if main_entry.subfolderitems %} | ||
{% for sub_entry in main_entry.subfolderitems %} | ||
{% if sub_entry.url %} | ||
{% assign slug_str = main_entry.slug | append: '/' | append: sub_entry.slug %} | ||
{% assign entry = ',' | append: docs_base_url | append: slug_str | append: sub_entry.url %} | ||
{% assign nav_pageList = nav_pageList | append: entry %} | ||
{%endif %} | ||
{% if sub_entry.subsubfolderitems %} | ||
{% for subsub_entry in sub_entry.subsubfolderitems %} | ||
{% assign slug_str = main_entry.slug | append: '/' | append: sub_entry.slug | append: '/' | append:subsub_entry.slug %} | ||
{% assign entry = ',' | append: docs_base_url | append: slug_str | append: subsub_entry.url %} | ||
{% assign nav_pageList = nav_pageList | append: entry %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
<!-- Add items from menu_side.json. --> | ||
{% for side_entry in site.data["menu_side"].sidemenu %} | ||
{% if side_entry.page != "Live Demo" %} | ||
{% assign entry = ',' | append: side_entry.url %} | ||
{% assign nav_pageList = nav_pageList | append: entry %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
|
||
{% assign nav_pageList = nav_pageList | remove_first: ',' | split: ',' %} | ||
|
||
|
||
{% assign page_url_parts = page.url | split: "?" %} | ||
{% assign page_url_base = page_url_parts[0] | remove: ".html" %} | ||
|
||
<!-- Remove trailing /, if any--> | ||
{% assign pos = page_url_base | size | minus: 1 %} | ||
{% assign last_char = page_url_base | slice: pos, 1 %} | ||
{% if last_char == "/" %} | ||
{% assign page_url_base = page_url_base | slice: 0, pos %} | ||
{% endif %} | ||
|
||
<!-- | ||
Debug print:<br><br> | ||
|
||
Current Page:<br> | ||
{{page.url}}<br> | ||
|
||
Normalized Current Page:<br> | ||
{{page_url_base}}<br> | ||
|
||
<br> | ||
Nav Pages:<br> | ||
{% for nav_page in nav_pageList %} | ||
{{nav_page}}<br> | ||
{% endfor %} | ||
--> | ||
|
||
|
||
<!-- | ||
Lets find where we are in the ordered | ||
document list by comparing url strings. Then if there's something previous or | ||
next, lets build a link to it. | ||
--> | ||
{% for nav_page in nav_pageList %} | ||
{% assign nav_page_url = nav_page %} | ||
{% assign nav_page_parts = nav_page_url | split: "/" %} | ||
<!-- If page.url ends in /index this is dropped. Account for this in name match --> | ||
{% if nav_page_parts[-1] == "index"%} | ||
{% assign norm_page_url = "" %} | ||
{% assign cnt = nav_page_parts.size | minus: 1 %} | ||
{% for part in nav_page_parts limit:cnt %} | ||
{% assign norm_page_url = norm_page_url | append: part | append: "/" %} | ||
{% endfor %} | ||
{% assign nav_page_url = norm_page_url %} | ||
{% endif %} | ||
|
||
<!-- Remove trailing /, if any--> | ||
{% assign pos = nav_page_url | size | minus: 1 %} | ||
{% assign last_char = nav_page_url | slice: pos, 1 %} | ||
{% if last_char == "/" %} | ||
{% assign nav_page_url = nav_page_url | slice: 0, pos %} | ||
{% endif %} | ||
|
||
|
||
{% if nav_page_url == page_url_base %} | ||
<div class="section-nav" style="text-align: center;"> | ||
{% if forloop.first %} | ||
<span class="prev disabled">Back</span> | ||
{% else %} | ||
{% assign previous = forloop.index0 | minus: 1 %} | ||
{% assign previous_page = nav_pageList[previous] %} | ||
<a href="{{ previous_page | relative_url }}" class="prev">Back</a> | ||
{% endif %} | ||
|
||
{% if forloop.last %} | ||
<span class="next disabled">Next</span> | ||
{% else %} | ||
{% assign next = forloop.index0 | plus: 1 %} | ||
{% assign next_page = nav_pageList[next] %} | ||
<a href="{{ next_page | relative_url }}" class="next">Next</a> | ||
{% endif %} | ||
</div> | ||
<div class="clear"></div> | ||
{% break %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, this page is pointed to by both the the docs and the sitemap link. I had to choose a single location in order to get a unique navigation order.