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

Fix paginate #180

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/_default/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ hasCJKLanguage = false # Set `true` for Chinese/Japanese/Korean languages.
defaultContentLanguageInSubdir = false
removePathAccents = true # Workaround for https://github.com/gohugoio/hugo/issues/5687

paginate = 10 # Number of items per page in paginated lists.
[pagination]
pagerSize = "10"

Comment on lines +40 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Revert changes to use Hugo's standard pagination configuration

The current changes might break Hugo's built-in pagination functionality due to:

  1. Using pagerSize instead of Hugo's standard paginate key
  2. Using a string value "10" instead of a number 10

Apply this diff to align with Hugo's pagination configuration:

-[pagination]
-pagerSize = "10"
+paginate = 10

Reference: Hugo's pagination documentation expects the paginate key with a numeric value at the root level of the configuration.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[pagination]
pagerSize = "10"
paginate = 10

💡 Codebase verification

Parameter name mismatch with theme's pagination configuration

The pagerSize parameter in the config file appears to be incorrect. The theme uses Hugo's standard pagination configuration which expects paginate instead of pagerSize. This is evidenced by:

  1. The example config in the theme using paginate = 10
  2. The pagination template using Hugo's built-in .Paginator object

The parameter should be renamed from pagerSize to paginate to properly control the number of items per page in paginated lists.

🔗 Analysis chain

Verify pagination usage in templates

Let's check if any templates or layouts depend on the pagination configuration.


Based on the search results, I found that pagination is used in the theme's templates, specifically in themes/academia/layouts/section/post.html which includes {{ partial "pagination" . }} and there's a dedicated pagination partial template at themes/academia/layouts/partials/pagination.html. Let me verify the actual implementation to understand how the pagerSize parameter is used.


Let me check the Hugo pagination configuration and its usage in the theme to fully understand the impact.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for pagination-related template code
echo "Checking for pagination usage in templates..."
rg -t html "paginate|pagination" layouts/

# Check for any custom pagination implementation
echo "Checking for custom pagination implementation..."
fd -e html -e go -e tmpl . layouts/ -x cat {} \; | rg "page[^a-z]|pager"

Length of output: 474


Script:

#!/bin/bash
# First, let's find the correct template directory structure
echo "Finding template-related directories..."
fd -t d "template|theme|layout" .

# Then, let's search for pagination-related files across the entire codebase
echo "Searching for pagination-related files..."
fd -t f "page|pagination|pager"

# Finally, let's search for pagination-related code patterns
echo "Searching for pagination usage in code..."
rg "paginate|pagination|pager|page[^a-z]"

Length of output: 107721


Script:

#!/bin/bash
# Check the pagination implementation in the theme
echo "Checking pagination partial template..."
cat themes/academia/layouts/partials/pagination.html

# Check if pagerSize is used in any template files
echo -e "\nChecking for pagerSize usage..."
rg "pagerSize" themes/

Length of output: 665


Script:

#!/bin/bash
# Check config files for pagination settings
echo "Checking config files for pagination settings..."
rg "paginate" config/ themes/

# Check for any other pagination-related template logic
echo -e "\nChecking for pagination template usage..."
rg -A 5 "Paginator" themes/

Length of output: 1389

enableEmoji = false
footnotereturnlinkcontents = "<sup>^</sup>"
ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"]
Expand Down
Loading