mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated site navigation generation to simplify prev/next etc.
Now the page order is controlled by _data/docs.yml only making it simple to add documents and edit their order.
This commit is contained in:
@@ -1,22 +1,39 @@
|
||||
<div class="section-nav">
|
||||
<div class="left align-right">
|
||||
{% if page.prev_section != null %}
|
||||
<a href="{{ site.baseurl }}/docs/{{ page.prev_section }}/" class="prev">
|
||||
Back
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="prev disabled">Back</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="right align-left">
|
||||
{% if page.next_section != null %}
|
||||
<a href="{{ site.baseurl }}/docs/{{ page.next_section }}/" class="next">
|
||||
Next
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="next disabled">Next</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{% comment %}
|
||||
Map grabs the doc sections, giving us an array of arrays. Join, flattens all
|
||||
the items to a comma delimited string. Split turns it into an array again.
|
||||
{% endcomment %}
|
||||
{% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %}
|
||||
|
||||
{% comment %}
|
||||
Because this is built for every page, 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.
|
||||
{% endcomment %}
|
||||
|
||||
{% for document in docs %}
|
||||
{% assign document_url = document | prepend:"/docs/" | append:"/" %}
|
||||
{% if document_url == page.url %}
|
||||
<div class="section-nav">
|
||||
<div class="left align-right">
|
||||
{% if forloop.first %}
|
||||
<span class="prev disabled">Back</span>
|
||||
{% else %}
|
||||
{% assign previous = forloop.index0 | minus: 1 %}
|
||||
{% assign previous_page = docs[previous] | prepend:"/docs/" | append:"/" %}
|
||||
<a href="{{ site.baseurl }}{{ previous_page }}" class="prev">Back</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="right align-left">
|
||||
{% if forloop.last %}
|
||||
<span class="next disabled">Next</span>
|
||||
{% else %}
|
||||
{% assign next = forloop.index0 | plus: 1 %}
|
||||
{% assign next_page = docs[next] | prepend:"/docs/" | append:"/" %}
|
||||
<a href="{{ site.baseurl }}{{ next_page }}" class="next">Next</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user