Closed RustLoverTheCoder closed 1 year ago
tl;dr
-- The app
directory and pages
directory work in extremely different ways, but the app
directory is still in beta and has a lot of work to do before it's at full feature pairity with the pages
directory. If you want to use the markdoc/next.js
renderer, you'll need to stick with the pages
directory.
Hi @Toursslivers! 👋🏽
I'm not officially associated with the markdoc project, but this is actually not a bug I don't think, either now or in the future.
The app
directory introduced in Next.js 13 is meant to explicitly create a separation between routing (which is done via folders and special files now rather than being "file based" in the same way that the pages
directory was) and data (which is meant to be fetched as part of the server component being rendered).
What this means practically is that the "old" way of putting md
files in the pages
directory and having them correspond to a route is not how the app
directory is designed to work. Instead, if you want to use the app
directory you'll need to manually gather and parse the Markdoc files.
The good news is that "where you put the markdoc files" is now a matter of preference. You could put them anywhere and organize them however you'd like. The Next.js team even hints at it being a good idea to potentially co-locate the data your components need in the route folder.
The long and short of this is that working with the pages
directory and the app
directory are wildly different, and in the future it's likely that you won't be using the markdoc/next.js
package and will instead be using the built-in react
renderer as part of a pipeline to manually parse, transform, and render your markdoc.
Having said all of that, the app
directory is still in beta, and can be used in concert with the pages
directory. So you can choose not to use it at this time and build things the more documented way in the pages
directory without issue.
Obviously, I could be wrong about a lot of this and the markdoc team can correct me, but based on the fairly radical changes between using the pages
directory and using the app
directory I'm not sure that this is a bug and if you really want to use the app
directory right now, the path forward is to treat the markdown files as data, parse them with the parse
and transform
methods, and then render them with the provided react
renderer.
Thanks for the thorough reply @birdcar agree with your guidance! The Markdoc Next.js plugin still works with v13 assuming you're keeping your Markdoc content under pages/
and following the integration outlined in https://markdoc.dev/docs/nextjs
I'm going to mark this as closed since it's not an issue but we'll keep an eye on this and future releases and update our docs and plugin as we see what the community wants to do and as the app
directory becomes more mature and stable. If you want to discuss more please open a new discussion thread!
Hi, for everyone stumbling upon this issue. I faced the same issue and figured out a work around and created a starter repository with instructions how my workaround works.
You can find the repository here: https://github.com/dylanmeivis/nextjs13-starter-markdoc#readme Related discussion: #329
Further discussion happening over here: https://github.com/markdoc/markdoc/discussions/329
What happened?
I've noticed that markdoc doesn't work with Next.js 13.
To reproduce
app/docs/xxx.md
Version
No response
Additional context
No response