如何在Next.js网站中添加Docusaurus网站作为路线

发布于 2025-02-06 04:29:47 字数 136 浏览 2 评论 0 原文

是否有人对如何将网站文档添加A /Docs页面添加到next.js应用程序中有任何建议?我已经查找了Docusaurus,但似乎已经是一个React应用程序本身。有没有办法将其集成到现有的Next.js应用中,或者还有其他解决方案吗?

非常感谢

Does anyone have any pointers on how to go about adding a /docs page for website documentation to a next.js app? I've looked up Docusaurus but it seems like it's already a react app itself. Is there a way to integrate it inside an existing next.js app or are there other solutions?

Many Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

安稳善良 2025-02-13 04:29:47

我最近遇到了一个类似的项目。

该项目最终在这里部署。

我正在使用Next.js and.js和js and.js和js and.js and.js和Docusaurus。

最重要的步骤是阅读下一个文档。

我在下一个文档中找到了覆盖方法。

重写允许您允许您映射到传入的请求路径到其他目标路径。

// next.config.mjs

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  rewrites: async () => [
    {
      source: "/doc",
      destination: "/doc/index.html",
    },
  ],
};

export default nextConfig;

我在博客上记录了详细的解决方案过程。

I recently came across a similar project.

The project is finally deployed here.

I am using the latest version of Next.js and Docusaurus.

The most important step is to read the Next.js documentation.

I found the override method in the Next.js documentation.

Rewrites allow you to map an incoming request path to a different destination path.

// next.config.mjs

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  rewrites: async () => [
    {
      source: "/doc",
      destination: "/doc/index.html",
    },
  ],
};

export default nextConfig;

I have recorded the detailed solution process on my blog.

How to use Docusaurus in Next.js projects?

无妨# 2025-02-13 04:29:47

一个想法可能是拦截请求并发送Docusaurus构建的HTML文件,并将所有其他文件放入公共文件夹中。

https:/medium.com/ Wesionary-Team/Render-HTML-File-In-In-In-next-JS-59281C46C05

也签约了此讨论。
https://github.com/vithub.com/vercel/next.js/discussions/discussions/12373

One idea might be to intercept the request and send the html file that docusaurus builds out, and putting all other files in the public folder.

https://medium.com/wesionary-team/render-html-file-in-pages-of-next-js-59281c46c05

Also checkout this discussion about it.
https://github.com/vercel/next.js/discussions/12373

_蜘蛛 2025-02-13 04:29:47

我已经使用Express进行了React应用程序。但是从来没有接下来。起初,接下来的多区域看起来可能是可能的,但这似乎并没有完成。因此,我的其他建议是尝试使用docs.domain.com并单独托管。然后,您将拥有一个 /docs URL或一个按钮,将其重定向到DOC域。

Firebase具有免费的托管,可让您设置多个站点。因此,在那里测试此设置应该很快,

我将积极地尝试使此设置与下一步合作,但我认为它不会因为它们的发展而起作用。因此,我会做上述建议,如果找到解决方法,我会发布更新。

I have done this with React apps using express. But never with Next. At first it looks like it would be possible with multi-zone in Next but that doesn't seem to do the job. So my other recommendation would be to try to use a docs.domain.com instead and host it separately. Then you have a /docs url or a button that redirects to the doc domain instead.

Firebase has free hosting and allows you to setup multiple sites. So it should be fast to test this setup there

I'm going to actively try to get this to work with Next myself but I do not think it will work because of how they are developed. So I would do the above recommendation and if I find a workaround, I'll post an update.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文