Skip to content
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

Documentation/Examples of Previous/Next functionality. #33

Closed
thiagodemellobueno opened this issue Apr 9, 2015 · 3 comments
Closed

Comments

@thiagodemellobueno
Copy link

Examples of how to implement previous/next functionality in templates would be greatly appreciated.

@nikmartin
Copy link

HI know this isn't a substitute for good docs, but the previous/next functionality is very simple.once the collection is built, the plugin just loops through the collection, adding a 'previous' and 'next' property to the file metadata, which is just the name of the previous and next file in the list of files I the collection. nothing is output unless you output it in your template. Something like:

<ul>
        {{#each collections.posts}}
            <li>
                <h3>{{this.title}}</h3>
                <article>{{this.contents}}</article>
<a href="{{this.previous}}">Prev</a>
  <a href="{{this.next}}">Next</a>  
</li>
        {{/each}}
    </ul>

@spsaucier
Copy link

In case others are seeing [Object object] when you try to use the above, try this instead:

    <div class="lesson-nav">
      {{#if previous}}
        <a class="prev" href="/{{{previous.url}}}">&larr; {{{previous.title}}}</a>
      {{/if}}
      {{#if next}}
        <a class="next right" href="/{{{next.url}}}">{{{next.title}}} &rarr;</a>
      {{/if}}
    </div>

@alexandrubau
Copy link

+1

@webketje webketje closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants