jpmorganchase / mosaic

https://mosaic-mosaic-dev-team.vercel.app

Home Page:https://mosaic-mosaic-dev-team.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make index suffix on URLs optional

james-nash opened this issue · comments

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 to https://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 the index 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.