Eliminate the need for prev_section and next_section metadata.

This commit is contained in:
Alan Scherger 2015-01-11 21:04:00 -08:00
parent 965e3a1173
commit c26f040bcf
31 changed files with 47 additions and 79 deletions

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Assets
prev_section: datafiles
next_section: migrations
permalink: /docs/assets/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Collections
prev_section: variables
next_section: datafiles
permalink: /docs/collections/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Configuration
prev_section: structure
next_section: frontmatter
permalink: /docs/configuration/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Continuous Integration
prev_section: deployment-methods
next_section: troubleshooting
permalink: /docs/continuous-integration/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Contributing
prev_section: upgrading
next_section: history
permalink: /docs/contributing/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Data Files
prev_section: collections
next_section: assets
permalink: /docs/datafiles/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Deployment methods
prev_section: github-pages
next_section: continuous-integration
permalink: /docs/deployment-methods/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Working with drafts
prev_section: posts
next_section: pages
permalink: /docs/drafts/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Extras
prev_section: plugins
next_section: github-pages
permalink: /docs/extras/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Front Matter
prev_section: configuration
next_section: posts
permalink: /docs/frontmatter/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: GitHub Pages
prev_section: extras
next_section: deployment-methods
permalink: /docs/github-pages/
---

View File

@ -2,7 +2,6 @@
layout: docs
title: History
permalink: "/docs/history/"
prev_section: contributing
---
## 2.5.3 / 2014-12-22

View File

@ -1,7 +1,6 @@
---
layout: docs
title: Welcome
next_section: quickstart
permalink: /docs/home/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Installation
prev_section: quickstart
next_section: usage
permalink: /docs/installation/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Blog migrations
prev_section: assets
next_section: templates
permalink: /docs/migrations/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Creating pages
prev_section: drafts
next_section: variables
permalink: /docs/pages/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Pagination
prev_section: permalinks
next_section: plugins
permalink: /docs/pagination/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Permalinks
prev_section: templates
next_section: pagination
permalink: /docs/permalinks/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Plugins
prev_section: pagination
next_section: extras
permalink: /docs/plugins/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Writing posts
prev_section: frontmatter
next_section: drafts
permalink: /docs/posts/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Quick-start guide
prev_section: home
next_section: installation
permalink: /docs/quickstart/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Resources
prev_section: sites
next_section: upgrading
permalink: /docs/resources/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Sites using Jekyll
prev_section: troubleshooting
next_section: resources
permalink: /docs/sites/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Directory structure
prev_section: usage
next_section: configuration
permalink: /docs/structure/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Templates
prev_section: migrations
next_section: permalinks
permalink: /docs/templates/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Troubleshooting
prev_section: deployment-methods
next_section: sites
permalink: /docs/troubleshooting/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Upgrading
prev_section: resources
next_section: contributing
permalink: /docs/upgrading/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Basic Usage
prev_section: installation
next_section: structure
permalink: /docs/usage/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Variables
prev_section: pages
next_section: collections
permalink: /docs/variables/
---

View File

@ -1,8 +1,6 @@
---
layout: docs
title: Jekyll on Windows
prev_section: configuration
next_section: posts
permalink: /docs/windows/
---

View File

@ -1,22 +1,48 @@
<div class="section-nav">
<div class="left align-right">
{% if page.prev_section != null %}
<a href="/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="/docs/{{ page.next_section }}/" class="next">
Next
</a>
{% else %}
<span class="next disabled">Next</span>
{% endif %}
</div>
<div class="clear"></div>
</div>
{% comment %}
Lets turn our yaml into a structured list of documents without titles.
{% endcomment %}
{% assign docs = site.data.docs | map: 'docs' %}
{% capture document_array_string %}
{% for doc in docs %}
{% assign last_last = forloop.last %}
{% for title in doc %}
{{title}}{% unless forloop.last and last_last %},{% endunless %}
{% endfor %}
{% endfor %}
{% endcapture %}
{% assign document_array = document_array_string | strip_newlines | split: ',' %}
{% comment %}
Because this is built for every page, lets find where we are in the document list by comparing url strings.
Then if there's something previous or next, lets build links to it.
Note: When arrays are accessed directly, they are zero based.
{% endcomment %}
{% for document in document_array %}
{% 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 = document_array[previous] | prepend:"/docs/" | append:"/" %}
<a href="{{ 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 = document_array[next] | prepend:"/docs/" | append:"/" %}
<a href="{{ next_page }}" class="next">Next</a>
{% endif %}
</div>
</div>
<div class="clear"></div>
{% break %}
{% endif %}
{% endfor %}