-
-
Notifications
You must be signed in to change notification settings - Fork 10
added renameLast and verbose options #133
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
base: master
Are you sure you want to change the base?
Conversation
lib/pagination.js
Outdated
@@ -78,6 +80,16 @@ function pagination(base, posts, options = {}) { | |||
}); | |||
} | |||
|
|||
if ((overwriteLatest && result.length > 1) || (overwriteLatest && explicitPaging && result.length === 1)) { | |||
const lastPage = result[result.length - 1]; | |||
lastPage.path = lastPage.path.replace(/\/page\/\d+\/?$/, '/latest/'); |
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.
https://github.com/hexojs/hexo-pagination?tab=readme-ov-file#usage
The url format may be diverse, and this matching method is not appropriate.
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.
Lines 44 to 54 in 0804e67
| Data | Description | | |
| ------------- | ------------------------------------------------- | | |
| `base` | Base URL | | |
| `total` | Total pages | | |
| `current` | Current page number | | |
| `current_url` | Path of the current page (which equals to `path`) | | |
| `posts` | The slice of posts for the current page | | |
| `prev` | Previous page number | | |
| `prev_link` | The path to the previous page | | |
| `next` | Next page number | | |
| `next_link` | The path to the next page | |
Each page's data contains current_url
prev_link
next_link
. Only modifying the path
will cause wrong reference
README.md
Outdated
| `layout` | Layout. This value can be a string or an array. | `['archive', 'index']` | | ||
| `data` | Extra data | `{}` | | ||
| `explicitPaging` | Number the first page. e.g. `page/1/index.html` | `false` | | ||
| `overwriteLatest`| Set the latest page name. e.g. `page/latest/index.html` | `false` | |
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.
I don't know if you have done any relevant testing. By default, articles are sorted in reverse order by date, so the first page is "latest".
However, different users may have different settings, so I would suggest that two options should be provided, freely choosing to overwrite the first page or the last page.
For this PR, I would recommend that call it "lastpage" instead of "latest"
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.
the objective is to have the article sorted in normal order, so page 1 has the oldest post and never changing.
reverse order is regenerating all pages because the order is changing.
my objective is to minimize the number of pages which are generated. With normal order it generates only 1 page each day, and not tenth of pages.
I start from the last page and navigate backward.
To achieve this I need to link the last page on my home, or I need to change the page link every time there is a new page.
test/index.js
Outdated
} | ||
result[result.length - 1].path.should.eql('/latest/'); | ||
}); | ||
it('overwriteLatest 2', () => { |
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.
It is recommended to summarize it, instead of naming it 123
thank you for the many comments and suggestions. I made few changes:
|
Co-authored-by: Uiolee <[email protected]> Signed-off-by: Marco Azimonti <[email protected]>
…and maintainability
93a1425
to
0c8dfcc
Compare
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.
merged the review
split test cases
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.
reviewed
check list
Description
Adding the option to have the last page to be latest which is convenient in case of reverse pagination.
Adding a verbose option to display the generated routes
Additional information