shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.

Home Page:https://nextra.site

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding multiple documentation.

aydinvivik opened this issue · comments

Hello, I have a scenario with multiple documentation and some articles are in more than one documentation. Instead of rewriting the same article for each documentation, can I create one globally and show it in the article I want?

pages
  -documentation-1
      _meta.json
      index.mdx
      started.mdx (Global)
      credits.mdx (Global)
  -documentation-2
      _meta.json
      index.mdx
      started.mdx (Global)
      credits.mdx (Global)
  -documentation-3
      _meta.json
      index.mdx
  _meta.json
  index.mdx
  started.mdx (Global)
  credits.mdx (Global)

Hello, aydinvivik,

Although I'm not the developer of this service, I'd be happy to assist you as much as I can.

As you rightly pointed out, it can be cumbersome to write the same article repeatedly across different documents. In such cases, exporting and importing Markdown files can be quite helpful.

For example, you can write the common content in a file named task-list.mdx and then import it into other MDX pages. Specifically, the content of task-list.mdx could look like this:

- [x] Code
- [x] Sleep
- [ ] Eat

To import this file into another page (for example, index.mdx), you would write the following:

import TaskList from './task-list.mdx'
 
<TaskList />

By doing this, the content defined in task-list.mdx will be displayed in other pages.

If you have any questions, please feel free to ask. I'd be happy to help if I can.

Docs: https://the-guild.dev/blog/nextra-2#markdown-import

@Fun117 Thank you very much for your feedback, I will try this.