Closed chriscalo closed 4 years ago
I have a preference over having only one way of doing things. If Goldpage wouldn't support parameterized rotues then yes I'd agree with you and the one way of doing things would be to use the name of .page.js
files and paths to determine the route.
Goldpage does support parameterized routes such as hello/:name
which means that there could be filenames like pages/hello\/:name/index.page.js
. For such a route I'd prefer having a route
page config instead.
If you have 20 pages then you'll have to write 20 route
strings. It's redundant I agree but I'd say worth it for the sake of simplicity.
Allowing only one way of doing things makes things simpler.
Very reasonable position. Thanks for giving it some thought 👍
If the config object returned from a
*.page.js
file doesn’t include aroute
field, can it be derived from its relative path in the pages directory?For example:
I created a small utility to do this. Here’s what its usage looks like:
And here’s the
fileroute
function:Goldpage is already transforming the paths of all
*.page.js
files into names likeindex
orfoo
orbar/index
, could the name be transformed into a route if a route isn't present on a page config object?