#How to check if a string is a valid Astro route?

6 messages · Page 1 of 1 (latest)

radiant monolith
#

I'm experimenting with making a hybrid site and a dynamic route to automatically redirect users to the correct part of the site based on their preferred language. Is there any way I can check whether a route is valid before redirecting a user to it? So far I have tried using Object.keys import.meta.globs("./**), but that seems to return a list of files, not a list of routes.

cerulean kelp
#

If these routes are collection based then you can just query that collection and redirect if the language/slug exists

radiant monolith
#

I guess they...could be?

cerulean kelp
#

How they are defined now? You could also just filter the list of files down to the ones you want

radiant monolith