Conversation
uiolee
left a comment
There was a problem hiding this comment.
Missing unit tests. If convenient, please add some test cases
lib/generator.js
Outdated
| perPage, | ||
| layout: ['archive', 'index'], | ||
| format: paginationDir + '/%d/', | ||
| explicitPaging: (config.archive_generator.explicit_paging || config.archive_generator.overwrite_latest || false), |
There was a problem hiding this comment.
Personally, I think overwrite_latest should not be added here, as this may confuse users. It makes it ambiguous whether to enable explicit_paging
lib/generator.js
Outdated
|
|
||
| if ((config.archive_generator.overwrite_latest || false) && pages.length > 0) { | ||
| const lastPage = pages[pages.length - 1]; | ||
| lastPage.path = lastPage.path.replace(/\/page\/\d+\/?$/, '/latest/'); |
There was a problem hiding this comment.
In my opinion, this destroys the unambiguity of explicit_paging.
I think adding an additional path will be better than overwriting it.
There was a problem hiding this comment.
this is not modifying if there is a single page. The objective is to have it changed even if there is 1 page. For the users is transparent, it the flag is set then all the pages (even if there is only one) end with /latest in the path
for example /tag/mytag/1 is renamed to /tag/mytag/latest and properly linked if you create a page with all the tags.
the overwrite is made on purpose so that is not duplicating pages (the static generator create the page), as the last page (with number) is never used. You can see the result in my blog.
|
maybe moving |
|
moving it to hexo-pagination is an option so it can be done once for all the plugin. |
Co-authored-by: Uiolee <22849383+uiolee@users.noreply.github.com> Signed-off-by: Marco Azimonti <git@azimonti.com>
There was a problem hiding this comment.
I moved the logic into hexo-pagination. If the implementation of hexo-pagination is fine and merged, then I can create a test case for this plugin also before the merge. Now I cannot create the fixture because hexo-pagination is not recognizing the new flag.
977bc7a to
7cbf134
Compare
7cbf134 to
df18260
Compare
check list
Description
Adding a flag for
explicitPagingintroduced in the version 4.0.0 of hexo-pagination. hexojs/hexo-pagination#114Adding the option to have the last page to be
latestwhich is convenient in case of reverse pagination.Additional information