Custom helper functions from integration for getStaticPaths()
#1169
openscript
started this conversation in
Proposal
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
getStaticPaths()
provides a helper function calledpaginate
. I propose making it possible for integrations to provide additional functions likepaginate
.Background & Motivation
With
getStaticPaths()
, the props and params are crafted for each page. Out of the box, Astro already provides apaginate
function to handle pagination. This is convenient, as not every project needs to implement this relatively complex requirement from scratch.However, projects often have other needs beyond pagination — for example, internationalization or grouping logic.
A common use case is internationalization, where translated pages need to be generated based on a content collection. Today, a typical approach is to provide a custom function called from within
getStaticPaths()
:The downside of this approach is that such helper functions don't have access to the same context or capabilities as the built-in
paginate
function. This limits their utility.That’s why I propose making it possible for integrations to provide custom utilities—similar to paginate—which can be used within
getStaticPaths()
and have access to the same context.Goals
getStaticPaths()
extensible from integrationsgetStaticPaths()
implementationsgetStaticPaths()
getStaticPaths()
logicExample
Beta Was this translation helpful? Give feedback.
All reactions