dillonkearns / elm-pages

Hybrid Elm framework with full-stack and static routes.
https://elm-pages.com
BSD 3-Clause "New" or "Revised" License
657 stars 96 forks source link

src/Page/Slug__.elm doesn't match / #228

Open TSFoster opened 3 years ago

TSFoster commented 3 years ago

I don't want the elm-pages site I'm building to treat the homepage any differently from any other first-level page (I'm using a headless CMS and the homepage has the same page type as any other page).

I ran elm-pages add Slug__ without issue, but when I run npm run start and visit http://localhost:1234/ or npm run build and look at the dist/index.html, I get the "No route found for …" error page.

dillonkearns commented 3 years ago

You'll also need to add it to the list of prerendered routes in routes, if you run the dev server it should tell you that it matches the Route but didn't find that specific page in the prerendered list. You'll need to add empty list as the dev server error suggests.

TSFoster commented 3 years ago

Sorry, I should have mentioned that I had added { slug = Nothing } to Page.Slug__.routes when trying to npm run build. It still doesn't work for src/Page/Slug__.elm how it does src/Page/Example/Slug__.elm. It creates dist/index.html, but the contents of it are the same as when running the dev server.

This is a screenshot of the dev server after running elm-pages add Slug__; elm-pages add Example.Slug__.

image

Edit: just want to clarify, / is the only route that doesn't work in this scenario. /foo, /example/ and /example/foo all match as expected.