Merge pull request #42 from ajdavis/prev-next-sibling
get_prev_sibling and get_next_sibling
This commit is contained in:
commit
a9668698c6
File diff suppressed because one or more lines are too long
|
@ -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 %}
|
||||
```
|
|
@ -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 %}
|
||||
```
|
|
@ -18,5 +18,23 @@
|
|||
</p>
|
||||
</div>
|
||||
{% 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>
|
||||
{% endblock %}
|
||||
|
|
|
@ -264,6 +264,14 @@ div.blog-post {
|
|||
}
|
||||
}
|
||||
|
||||
div.nav-prev {
|
||||
float: left;
|
||||
}
|
||||
|
||||
div.nav-next {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.page-banner {
|
||||
margin: 15px 0;
|
||||
background-size: cover;
|
||||
|
|
Loading…
Reference in New Issue