doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.62k stars 1.46k forks source link

"Page not found" for new pages without the restart of dev-build #1338

Closed lttb closed 4 years ago

lttb commented 4 years ago

Bug Report

Describe the bug

There is a gatsby 404 error for new pages without restart of dev-build.

The page after creation is visible in the sidebar:

image

But it's not accessible by the link and the route:

image

It's required to restart the build to make the new page work.

To Reproduce

  1. yarn create docz-app docz-app-basic --example basic
  2. yarn dev
  3. open the site
  4. create src/hello.mdx
  5. try to visit the new page, see 404 gatsby error

Expected behavior

It's expected that the new page will be available on fly.

Environment

ShinyLeee commented 4 years ago

Facing the same issue,do you find any workaround?

twf-nikhila commented 4 years ago

Facing same problem, the only way I figured out is terminating npm and building it again.

kayosouza commented 4 years ago

Same thing here, pages are not created on the .docz folder when the new build is generated.

lttb commented 4 years ago

it seems that an issue was caused by this fix: https://github.com/doczjs/docz/commit/dad228fff5cbe4c9f989d96a16f8f3c598b98bea#diff-10b0f76ede3ea173b8dda2af33c892a9

that fix stops completely re-creating all pages on every file change, but it also looks like that it stops creating new pages too

in example, exports.createPages = require('./lib/createPagesStatefully') works fine

so, in general, we should make efficient incremented updates for already created pages, but also still create new pages too

as I understood gatsby docs well (https://www.gatsbyjs.org/docs/node-apis/#createPagesStatefully), with createPagesStatefully it's required to watch pages independently, like this plugin: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-page-creator/src/gatsby-node.js#L60

but maybe we can just call createPage only for new pages on a simple createPages event?

rakannimer commented 4 years ago

Hey @lttb,

I think you accurately described the problem and the solution. We need to replace createPagesStatefully back with createPagr

rakannimer commented 4 years ago

Hey @lttb,

I think you accurately described the problem and the solution. We need to replace createPagesStatefully back with createPages and only create if we receive a new file event or add a file-added listener in createPagesStatefully.

Anyone up for submitting a PR? Happy to help with it!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jeffsjs commented 4 years ago

Any precision of the solution?

smeevil commented 3 years ago

This is still an issue, any outlook on a solution?