Skip to content
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

Route override fallbacks #326

Open
jimafisk opened this issue May 29, 2024 · 0 comments
Open

Route override fallbacks #326

jimafisk opened this issue May 29, 2024 · 0 comments

Comments

@jimafisk
Copy link
Member

It's pretty common to have route overrides in your plenti.json config that use field values from your content source, for example:

"routes": {
  "pages": ":fields(url)"           
},                     

The downside is that if the url field is left blank, it could conflict with the homepage route and cause issues. One solution would be to make it a required field (#325). Alternatively, we could provide an "or" fallback option like:

"routes": {
  "pages": ":fields(url) || /:filename"           
},

The logic being, if any evaluated value (anything between ( and ), in this case url) is blank (or determined to not be valid for a URL), then use the "or" case instead. This would apply to all evaluated values in a chain, for example if the route override was /:fields(first_name)/:fields(last_name) it would use the "or" case if either first_name or last_name was blank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant