Tried upgrading to Contentlayer2 today because:
- Rendering the different pages (especially hubs
/projects
for e.g) and the individual posts took too long - Solution seemed elegant - one config file, typed frontmatter with custom fields, etc
Immediately ran into several problems:
- Contentlayer has long since been deprecated
- Contentlayer2 seems like a plug-and-play update but after a wrong misstep with
npm update
I kept encountering:
A React Element from an older version of React was rendered. This is not supported. It can happen if:
- Multiple copies of the "react" package is used.
- A library pre-bundled an old copy of "react" or "react/jsx-runtime".
- A compiler tries to "inline" JSX instead of using the runtime.
There were no solutions to this.
- Did not understand the error
Error: Page missing param in "generateStaticParams()", which is required with "output: export" config.
Ended up removingoutput: export
. - Took a while to understand how
contentLayer
handled fields. If you want custom slugs and urls, use a different field e.g.customSlug
forslug
;link
instead ofurl
and custom fields to point toslug
andurl
because that's what's used for routing, etc. - I also tried using next-mdx-remote but it was asking me to turn the slug pages into client-side rendered components so that defeats the purpose
In the end, given how my website layout is pretty much decided and will be content-rich, I am migrating to Astro.