content-collections icon indicating copy to clipboard operation
content-collections copied to clipboard

[DOCS] async `withContentCollections`

Open mxkaske opened this issue 1 year ago • 2 comments

This is more informational! Thanks for that awesome library!

We faced an issue within next.config.js that was not mentioned in the docs so far: the withContentCollections returns a promise and therefore needs to be awaited in some cases (e.g. when using multiple config extensions).

// next.config.js
module.exports = withSentryConfig(async () => await withContentCollections(nextConfig), { ... });

vs.

// next.config.js
module.exports = withContentCollections(withSentryConfig(nextConfig, { ... }));

The referenced change for OpenStatus: https://github.com/openstatusHQ/openstatus/pull/1084/files#diff-a5de0fa0d80f14a44e9bdf2ed5d0cbb3a7bd5fdcacfbc1d03b5dcb57fc4943c1R59

Nextjs docs: https://nextjs.org/docs/messages/promise-in-next-config

mxkaske avatar Nov 05 '24 15:11 mxkaske

That is the reason why the documentation mentions that content collections must be the outermost plugin: Next adapter documentation.

Perhaps we could explain more about why it should be the outermost plugin.

sdorra avatar Nov 05 '24 19:11 sdorra

Oh well, my bad, can’t read.

And if two plugins claim to be the outermost plugin, you can still await it. :)

mxkaske avatar Nov 05 '24 22:11 mxkaske