contentlayerdev / contentlayer

Contentlayer turns your content into data - making it super easy to import MD(X) and CMS content in your app
https://www.contentlayer.dev
MIT License
3.31k stars 202 forks source link

Bug in updating nextjs import #546

Closed naward-cs closed 11 months ago

naward-cs commented 1 year ago

I am using nextjs 13.4.19 and the latest versions of contentlayer and next-contentlayer.

Currently using

export default makeSource((sourceKey = 'main') => ({
  syncFiles: (contentDir) => syncContentFromGit({ contentDir, gitTag: sourceKey }),
  contentDirPath: `content/docs-${sourceKey}`,
  contentDirInclude: ['docs'],
  documentTypes: [Docs],
  disableImportAliasWarning: true,
}))

as a way to download -> build latest content from github, just like you have in the example. After building and starting nextjs; nextjs is able to pull content into app/[...slug]/page.tsx. When using dev mode, updating content, I am able to run yarn contentlayer generate with not issues. The content is updated and nextjs shows updated content.

However, the issue is in production. After initial build and start of nextjs, when yarn contentlayer generate is ran, contentlayer pulls and updates the .contentlayer/generated folder, however, nextjs will not update the content. I have attempted in running revalidatePath, and even tried with and without generateStaticParams. Unfortunately nextjs continues to not update the content.

Of note: next-remote-mdx does update nextjs when content is added and/or removed. When I looked at the source code for next-remote-mdx I happened to notice there is a async/await function to recheck the data. When I look at contentlayer's source code, everything is a "const", so I have feeling nextjs is building with the concept nothing coming out of ".contentlayer/generated" will ever change until the next build is executed.

stale[bot] commented 11 months 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.