-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Explicit paging #216
base: master
Are you sure you want to change the base?
Explicit paging #216
Changes from 3 commits
2a047bf
46d7d65
59ebcaa
ed35793
6268dad
977bc7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,25 @@ module.exports = function(locals) { | |
function generate(path, posts, options = {}) { | ||
options.archive = true; | ||
|
||
result.push(...pagination(path, posts, { | ||
const pages = pagination(path, posts, { | ||
perPage, | ||
layout: ['archive', 'index'], | ||
format: paginationDir + '/%d/', | ||
explicitPaging: (config.archive_generator.explicit_paging || config.archive_generator.overwrite_latest || false), | ||
data: options | ||
})); | ||
}); | ||
|
||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion, this destroys the unambiguity of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
} | ||
|
||
if (config.archive_generator.verbose || false) { | ||
pages.forEach(page => { | ||
console.log(`Generated archive route: ${page.path}`); | ||
}); | ||
} | ||
result.push(...pages); | ||
} | ||
|
||
generate(archiveDir, allPosts); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Personally, I think
overwrite_latest
should not be added here, as this may confuse users. It makes it ambiguous whether to enableexplicit_paging