Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root "/" doesn't get prerendered with Github Pages preset #2333

Closed
sby1ce opened this issue Apr 2, 2024 · 3 comments · Fixed by #2334
Closed

Root "/" doesn't get prerendered with Github Pages preset #2333

sby1ce opened this issue Apr 2, 2024 · 3 comments · Fixed by #2334
Labels
bug Something isn't working preset:github-pages

Comments

@sby1ce
Copy link
Contributor

sby1ce commented Apr 2, 2024

Environment

nitro 2.9.5

Reproduction

In nitro.config.ts

export default defineNitroConfig({
  srcDir: "server",
  preset: "github-pages"
});

https://codesandbox.io/p/github/unjs/nitro/csb-rqd4sc/draft/old-sky?file=%2Fnitro.config.ts%3A6%2C1

Describe the bug

nitro build with "github-pages" preset doesn't prerender index.html file like with the "static" preset which doesn't seem to be intended behaviour.
this is due to github pages preset adding 404.html route in prerender object
https://github.com/unjs/nitro/blob/eb377abf3332f431b388d3fa53b2c8786f832183/src/presets/github-pages.ts#L10-L15

this check is no longer true
https://github.com/unjs/nitro/blob/2bce7adafd988ffef186b70012a4b45087f11ca5/src/prerender.ts#L40-L43

so index.html doesn't get prerendered

Additional context

manually adding "/" to routes array should fix this but maybe there's a better solution

Logs

No response

@pi0
Copy link
Member

pi0 commented Apr 2, 2024

please share a runnable reproduction

@sby1ce
Copy link
Contributor Author

sby1ce commented Apr 2, 2024

here you are
https://codesandbox.io/p/github/unjs/nitro/csb-rqd4sc/draft/old-sky?file=%2Fnitro.config.ts%3A6%2C1

@pi0
Copy link
Member

pi0 commented Apr 2, 2024

Thanks for repro. Feel free to make a PR for adding / by default for github-pages 👍🏼

@pi0 pi0 added bug Something isn't working preset:github-pages and removed pending triage labels Apr 2, 2024
@pi0 pi0 closed this as completed in #2334 Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preset:github-pages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants