Static Site: Routing requests - Match to transformed Slug #24436
VinayaSathyanarayana
started this conversation in
Ideas
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the feature you'd like to request
Suppose I have
pages/ads/[lat]/[lon].js
I want all the following requests
pages/ads/12.3456/98.7654
pages/ads/12.3567/98.7543
pages/ads/12.3345/98.7876
to match a statically generated page (using getStaticProps )
pages/ads/12.3/98.7
Note: For simplicity - I have just truncated the digits
We can extend the use case to more sophisticated URL transformations.
Describe the solution you'd like
The match logic for statically generated pages has to factor a predefined transformation of the URL.
The pre defined transformation could be a function that takes the arguments in square brackets and provides the new values
Ability to modify slugs and reuse the pre-rendered page will be useful for a number of use cases.
We need to enhance rewrites with the ability to modify slugs using a custom function so that the next-server can reuse an existing pre-rendered page.
Note: If my reading of the code is correct, the handleRewrites function needs to be enhanced.
Developers should be able to provide their custom transformation function as part of the next.config.js file
Sample Use Cases:
Truncation like in the lat, long example given above
... There are a number of interesting uses for this.
@Timer @timneutkens @ijjk Please include it in the roadmap and prioritize it.
Describe alternatives you've considered
The option I can think of is getServerSideProps, but that does not provide the benefits of Static Site Generation
Will be really useful in a number of usecases
Beta Was this translation helpful? Give feedback.
All reactions