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

Possibility to do a next / prev based on the content type? #319

Closed
mpas opened this issue Jun 4, 2014 · 10 comments
Closed

Possibility to do a next / prev based on the content type? #319

mpas opened this issue Jun 4, 2014 · 10 comments

Comments

@mpas
Copy link

mpas commented Jun 4, 2014

When trying to implement Prev / Next for a specific content type i run into a problem when i have another content type like for exampe pages.

        {{if .Next}}
        <li><a class="previous" href="{{.Next.Permalink}}">← {{.Next.Title}} </a></li>
      {{end}}
      {{if .Prev}}
        <li><a class="next" href="{{.Prev.Permalink}}">{{.Prev.Title}} →</a></li>
      {{end}}

This results in the fact that 'post' and ' page' contenttypes are mixed. Is there a way to limit the Prev / Next to a specific contenttype?

I would like to have only Prev / Next for the contenttype 'post'

@spf13
Copy link
Contributor

spf13 commented Jun 4, 2014

This feature doesn't currently exist. We can add it though. Need to figure out the right way to do it so it works for everyone.

@mpas
Copy link
Author

mpas commented Jun 6, 2014

Would be great! Thanks for picking this up!

@yacoob
Copy link
Contributor

yacoob commented Aug 27, 2014

@mpas, I'm using something like that:

{{ with .Prev }}{{ if eq .Type "post" }}
    <a href='{{ .RelPermalink }}'>...</a>
{{ end }}{{ end }}

That only works if your pages are at the beginning or end of the list.

@chibicode
Copy link

👍 I'd appreciate this feature. @yacoob doesn't that approach fail if .Prev isn't of the post type?

@bep
Copy link
Member

bep commented Mar 8, 2015

In 0.13 there is .NextInSection, .PrevInSection.

@chibicode
Copy link

@bep totally missed that...thank you!

@chibicode
Copy link

It doesn't seem to work unless you're on a section page though. It's returning me nothing on a single post page.

@bep
Copy link
Member

bep commented Mar 9, 2015

It works for what it says it does. Nothing more, nothing less.

@bep bep added the Stale label Feb 27, 2017
@bep
Copy link
Member

bep commented Mar 1, 2017

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

@bep bep closed this as completed Mar 27, 2017
moorereason pushed a commit to moorereason/hugo that referenced this issue Sep 13, 2019
Replaced fmt.Frpintf calls with fmt.Fprint when there's no formatting…
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants