Merge pull request #42 from ajdavis/prev-next-sibling

get_prev_sibling and get_next_sibling
This commit is contained in:
Armin Ronacher 2016-01-07 00:00:52 +01:00
commit a9668698c6
5 changed files with 75 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,24 @@
title: get_next_sibling
---
summary: Returns the next record.
---
type: method
---
body:
Get the next record in this record's parent's list of children.
If the parent record has pagination enabled, then `get_prev_sibling` and
`get_next_sibling` use the pagination query to filter and order the children.
Otherwise, the parent's standard configuration for children is used.
See [the pagination guide :ref](../../../../guides/pagination/) and the
[page order guide :ref](../../../../guides/page-order/).
## Example
```html+jinja
{% set newer = this.get_next_sibling() %}
{% if newer %}
<a href="{{ newer|url }}">Next article: {{ newer.title }}</a>
{% endif %}
```

View File

@ -0,0 +1,24 @@
title: get_prev_sibling
---
summary: Returns the previous record.
---
type: method
---
body:
Get the previous record in this record's parent's list of children.
If the parent record has pagination enabled, then `get_prev_sibling` and
`get_next_sibling` use the pagination query to filter and order the children.
Otherwise, the parent's standard configuration for children is used.
See [the pagination guide :ref](../../../../guides/pagination/) and the
[page order guide :ref](../../../../guides/page-order/).
## Example
```html+jinja
{% set older = this.get_prev_sibling() %}
{% if older %}
<a href="{{ older|url }}">Previous article: {{ older.title }}</a>
{% endif %}
```

View File

@ -18,5 +18,23 @@
</p> </p>
</div> </div>
{% endcall %} {% endcall %}
{% set older = this.get_next_sibling() %}
{% set newer = this.get_prev_sibling() %}
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
{% if older %}
<div class="nav-prev">
<a href="{{ older|url }}">Previous: {{ older.title }}</a>
</div>
{% endif %}
{% if newer %}
<div class="nav-next">
<a href="{{ newer|url }}">Next: {{ newer.title }}</a>
</div>
{% endif %}
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -264,6 +264,14 @@ div.blog-post {
} }
} }
div.nav-prev {
float: left;
}
div.nav-next {
float: right;
}
div.page-banner { div.page-banner {
margin: 15px 0; margin: 15px 0;
background-size: cover; background-size: cover;