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

Removing links to previous and next post #123

Open
ajdinre opened this issue Aug 26, 2020 · 3 comments
Open

Removing links to previous and next post #123

ajdinre opened this issue Aug 26, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ajdinre
Copy link

ajdinre commented Aug 26, 2020

Hi,

I've used your theme and I think this would be a good feature. In post Params, we can insert another value like cleanPage = true. This would be useful here:

<div class="pagination">
  {{if .Params.cleanPage}}
  <div></div>
  {{else}}
    {{if .PrevInSection}}
      <a class="pagination__item" href="{{.PrevInSection.Permalink}}">
          <span class="pagination__label">Previous Post</span>
          <span class="pagination__title">{{.PrevInSection.Title}}</span>
      </a>
    {{end}}

    {{if .NextInSection}}
      <a class="pagination__item" href="{{.NextInSection.Permalink}}">
        <span class="pagination__label">Next Post</span>
        <span class="pagination__title" >{{.NextInSection.Title}}</a>
      </a>
    {{end}}
    {{end}}
</div>

please note, there has to be something in the first part of the if statement.

I'd add just one variable called cleanPost to page parameters and that parameter would remove the pagination. This would be useful on pages like /about, /cv, /resources etc.

Edit: i just wanted to ask if this was an okay feature to add, I could make a PR for it.

@SanchithHegde
Copy link
Contributor

@ajdintrejic I'd like to suggest a modification:

{{ if not .Params.cleanPage }}
  <div class="pagination">
    {{ if .PrevInSection }}
      <a class="pagination__item" href="{{ .PrevInSection.Permalink }}">
        <span class="pagination__label">Previous Post</span>
        <span class="pagination__title">{{ .PrevInSection.Title }}</span>
      </a>
    {{ end }}

    {{ if .NextInSection }}
      <a class="pagination__item" href="{{ .NextInSection.Permalink }}">
        <span class="pagination__label">Next Post</span>
        <span class="pagination__title" >{{ .NextInSection.Title }}</a>
      </a>
    {{ end }}
  </div>
{{ end }}

I haven't tested this locally, but I believe this should work. Let me know if it doesn't.

Another approach would be to conditionally display the pagination partial by updating single.html#L21 like so:

{{ partial "tags.html" .}}
{{ if not .Params.cleanPage }} {{ partial "post-pagination.html" .}} {{ end }}

I personally feel that using a parameter like pagination: true would be more self-explanatory, in which case:
{{ if not .Params.cleanPage }}
would be replaced by
{{ if .Params.pagination }}

@jakewies
Copy link
Owner

This is a great idea. There's a lot of opinions about the usefulness of pagination in blog posts these days. So thank you for bringing it up @ajdintrejic . I agree with the semantics proposed by @SanchithHegde :

{{ if .Params.pagination }} {{ partial "post-pagination.html" .}} {{ end }}

Would you be open to making a contribution @ajdintrejic ?

@jakewies jakewies added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Oct 18, 2020
@ajdinre
Copy link
Author

ajdinre commented Oct 18, 2020

Thanks, I'll make changes and do a pr in couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants