-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
We don't have to use libraries.source.parse and libraries.source.stringify for next and previous page anymore, so we can simplify this code: https://github.com/chakra-ui/frontity-chakra-ui-theme/blob/master/packages/frontity-chakra-theme/src/components/archive/pagination.js#L63-L78
const { totalPages } = state.source.get(state.router.link);
const { path, page, query } = libraries.source.parse(state.router.link);
const isThereNextPage = page > 1;
const isTherePreviousPage = page < totalPages;
const nextPageLink = libraries.source.stringify({
path,
page: page + 1,
query,
});
const prevPageLink = libraries.source.stringify({
path,
page: page - 1,
query,
});And just use the next and previous we get from data:
const { totalPages, route, page, next, previous } = state.source.get(
state.router.link
);Please note that path has been renamed and is now route.
Docs: https://docs.frontity.org/api-reference-1/wordpress-source#state
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers