-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Improve pagination performance #8602
Conversation
Test site... InstructionsClone this branch of the repository and build the site. git clone --single-branch -b hugo-github-issue-8602 https://github.com/jmooring/hugo-testing hugo-github-issue-8602
cd hugo-github-issue-8602
npm install
hugo
npx serve Notes:
Site StructureThere are 10 content types (sections):
Visit each section to see an example of the pagination format as it varies with the number of pagers. Expected Counts
FormatThere are two display formats: default and terse. The "default" format:
The "terse" format:
To use the "default" format, these are equivalent:
To use the "terse" format:
This approach will allow us to add alternate formats in the future without changing the appearance of existing sites. I based the formats on a review of pagination formats from Google, Bing, and Amazon. See https://gist.github.com/jmooring/94e6e0bb0568ae5cdbae3372eb450111. StyleWhile I have applied minimal styling to this test site, the Pull Request does not contain any CSS. Site creators continue to be responsible for styling. ValidationThe output is valid HTML5 per https://validator.w3.org/. Scores from Google Lighthouse:
PerformanceBuild times are the average of 3 runs.
|
These calls are equivalent: {{ template "_internal/pagination.html" . }} {{ template "_internal/pagination.html" (dict "page" .) }} {{ template "_internal/pagination.html" (dict "page" . "format" "default") }} To use an alternate format: {{ template "_internal/pagination.html" (dict "page" . "format" "terse") }} Fixes #8599
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this looks good now, but with the added complexity we need a minimal test for the variants.
Could you add the variants and some very simple assertions to TestEmbeddedTemplates in hugolib package?
Note that I'm mostly worried about someone making a "cometic change" months from now, introducing a nil-pointer or something.
Added minimal test for variants; assertions for first pager only. |
Hey, I have thought about this while sleeping this weekend, and the internals looks very good -- but I'm not sure adding a {{ template "_internal/pagination.html" . }}
{{ template "_internal/pagination.html" (dict "page" .) }}
{{ template "_internal/pagination.html" (dict "page" . "format" "default") }}
{{ template "_internal/pagination.html" (dict "page" . "format" "terse") }} Would be covered by: {{ template "_internal/pagination.html" . }}
{{ template "_internal/pagination-terse.html" . }} Which I think is easier to explain to people. What do you think? |
I started out with something like this:
Or to call it with sensible defaults:
But I was concerned that you would say, "This is too complicated." So I simplified, but perhaps I shouldn't have. I like the above better than what I finished with, and I would be happy to revert to this approach, including test cases. |
I would have said that. This needs to be maintained and explained to people. With that set of options, the current setup would make sense -- but do people really want/need that? |
I apologise if this sounds too stupid/ignorant -
Also, if it helps, your comment here #8602 (comment) certainly makes much more sense than the OP. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
These calls are equivalent:
To use an alternate format:
Fixes #8599