mosaic
mosaic copied to clipboard
Make index suffix on URLs optional
Currently, where a directory contains an index.mdx
file, Mosaic will ensure that the corresponding URL ends in index
. For example:
- Source:
foo/bar/index.mdx
- URL:
https://example.com/foo/bar/index
Requests to the URL https://example.com/foo/bar
will be redirected to the corresponding https://example.com/foo/bar/index
URL.
It would be nice if there was an option to change the behaviour so that it becomes:
- Source:
foo/bar/index.mdx
- URL:
https://example.com/foo/bar
-
https://example.com/foo/bar/index
would be a permanent redirect tohttps://example.com/foo/bar
This is the behaviour we would like for the Salt site as:
- We get more succinct URLs (easier to read, share verbally, guess, etc.)
- It's more inline with how out-of-the-box Next.js behaves and indeed many other site generation tools where
index.md|html|whatever
files tend to be served up at URLs whose path omits theindex
part.
I suggest that this becomes an opt-in option though (perhaps via mosaic.config.js
?), so that other Mosaic-based sites don't suddenly have all their URLs change upon upgrading.
Note that the non-index-suffixed URLs would also need to be reflected in any auto-generated links for site navigation, breadcrumbs, etc.