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

prerender: {
routes: [
// https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-custom-404-page-for-your-github-pages-site
"/404.html",
],
},

this check is no longer true

nitro/src/prerender.ts

Lines 40 to 43 in 2bce7ad

// Crawl / at least if no routes are defined
if (nitro.options.prerender.crawlLinks && routes.size === 0) {
routes.add("/");
}

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