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

Pagination #69

Open
ghost opened this issue Sep 15, 2019 · 5 comments
Open

Pagination #69

ghost opened this issue Sep 15, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Sep 15, 2019

Go Hyde uses Poole, which has styling for pagination:

hyde/static/css/poole.css

Lines 354 to 359 in 62d338f

/*
* Pagination
*
* Super lightweight (HTML-wise) blog pagination. `span`s are provide for when
* there are no more previous or next posts to show.
*/

Poole utilizes this pagination for Jekyll:

https://github.com/poole/poole/blob/c0d52e1e/index.html#L22-L33

as does Jekyll Hyde:

https://github.com/poole/hyde/blob/7c7f7550/index.html#L22-L37

but Go Hyde doesnt utilize the pagination:

hyde/layouts/index.html

Lines 1 to 18 in 62d338f

{{ define "main" -}}
<div class="posts">
{{ range .Site.RegularPages -}}
<article class="post">
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}" class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</time>
{{ .Summary }}
{{ if .Truncated }}
<div class="read-more-link">
<a href="{{ .RelPermalink }}">Read More…</a>
</div>
{{ end }}
</article>
{{- end }}
</div>
{{- end }}

@ghost
Copy link
Author

ghost commented Sep 15, 2019

As a workaround, I swapped out the Poole pagination CSS for this:

https://github.com/gohugoio/hugo/blob/c0d7188e/docs/themes/gohugoioTheme/assets/css/_hugo-internal-template-styling.css#L2-L27

Then edit the layout:

diff --git a/layouts/index.html b/layouts/index.html
index ec6d2eb..8ac316e 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -1,6 +1,6 @@
 {{ define "main" -}}
 <div class="posts">
-{{ range .Site.RegularPages -}}
+{{ range .Paginator.Pages -}}
 <article class="post">
   <h1 class="post-title">
     <a href="{{ .Permalink }}">{{ .Title }}</a>
@@ -15,4 +15,5 @@
 </article>
 {{- end }}
 </div>
+{{- template "_internal/pagination.html" . }}
 {{- end }}

@sandipb
Copy link

sandipb commented Dec 11, 2019

Also the default list of pages includes posts as well as pages and it seems to be a giant mess.

I saw in a different theme (blackburn) that they were instead ranging over this, which makes way more sense, giving us just a list of posts.

...
{{ range ( .Paginate (where .Site.RegularPages "Type" "post")).Pages -}}
...

@bep
Copy link
Collaborator

bep commented Dec 11, 2019

Also the default list of pages includes posts as well as pages and it seems to be a giant mess.

Not sure what you mean by "posts as well as pages"... but if you want to change the paginator for the home page, you need to use the .Params.mainSections slice to do the filtering. This is a theme and not all people have posts as a section.

@sandipb
Copy link

sandipb commented Dec 11, 2019

Ah, got that. I didn't realize that posts are not present by default.

But is the expectation that the default output of index.html will be:
a) All the pages
b) All types of pages? (Post, regular pages, etc). By mistake was assuming that the most common case was blogs with a mix of posts and pages, and the default view that of a list of posts and pages as links on the sides. But you are right. I have seen quite a few blogs, which are just a collection of pages without any post.

@bep
Copy link
Collaborator

bep commented Dec 11, 2019

If you use .Params.mainSections it will get a sensible default that you can override if you want.

Ngalstyan4 pushed a commit to Ngalstyan4/narekg-hyde that referenced this issue Jul 19, 2020
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

2 participants