Next.js Discord

Discord Forum

Export to markdown

Unanswered
Northern Shrike posted this in #help-forum
Open in Discord
Northern ShrikeOP
Has anyone ever toyed with making Next.js output *.md routes alongside HTML routes, with a Markdown content type?

I'm happy to handle outputting the content of those md routes but I'm unsure where to hook into Next.js router / build process to ensure the routes are created and to give me a place to produce content for them. My website currently parses MDX content (which I'll know how to convert back to pure MD) and generates routes for each MDX file. My primary concern is to let NextJS handling the .md route creation so I don't have to consolidate two build processes into the same output prior to deploying my site.

2 Replies

Northern ShrikeOP
Thanks @American Sable!

To give more context, this is to power the Storybook docs. We currently use Next.js to serve docs, but we build our content from MDX with our own [compile logic](https://github.com/storybookjs/web/blob/main/apps/frontpage/lib/get-page.tsx#L68) using https://www.npmjs.com/package/next-mdx-remote.

My understanding of the topic is we'd want to add another compile from MDX to MD (easy peasy) and tell Next.js to serve either content, either based on routes, or based on user agent preferred content types. I don't know nextjs well at all so I don't know if we can use a [Proxy](https://nextjs.org/docs/app/getting-started/proxy) to serve different content directly rather than redirect.