I was wondering if there's an option to create a Gatsby page with optional URL parameters of sort. Let's say that I've got listing of articles with an URL set to /articles/:articleID
- this works really well, but the /articles
page is just blank, without errors or anything and I'd like to create a handler page for that, maybe a 404 or a list of all articles, for example.
AFAIK Gatsby uses React-Router, so I changed my URLs to /articles/:articleID?
, but it still doesn't work.
I'm creating all these pages with createPages
API, like this:
// ...
createPage({
path: page.url,
matchPath: `${page.url}${pageParams}`,
component: path.resolve(`./src/templates/${page.template}.js`),
context: {
...page.props,
}
});
where page
is a simple object that contains data like url
, template
and stuff.
pageParams
is just a string that looks like this: /:articleID?
.
Any tips on how to handle the page without any parameters? Because the template isn't loaded, but there is also no error for that page.