我有一个使用 Docusaurus v2 制作的网站,当前包含文档。但是,我想添加工作流程列表的页面,如果单击列表中的工作流程,将向用户显示该工作流程的其他详细信息的页面。目前它似乎docusaurus.config 正在处理大部分路由,但是有没有办法我可以添加动态路由,例如/workflows/:id?我制作了一个单独的独立应用程序,其中有一个 Router 对象,如果我的 App.js 如下所示,它就可以工作:
// App.js
import Navigation from './Navigation'
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom';
function App() {
return (
<Router>
<Navigation />
<Switch>
<Route path="/" exact component={Home}></Route>
<Route path="/workflows" exact component={Workflows}></Route>
<Route path="/workflows/:id" component={WorkflowItem}></Route>
</Switch>
</Router>
)
}
Run Code Online (Sandbox Code Playgroud)
是否可以在 Docusaurus 中的某个位置添加路由器?谢谢!
是否可以为每个页面运行一些自定义脚本?
例如,我想alert(1);在每个页面上运行。我怎样才能在不使用任何组件的情况下做到这一点?
我知道可以通过创建 jsx 组件并在每个 .mdx 文件中使用它来完成(但每个文档都应该是一个 .mdx 文件)。所以这不是我要找的东西。
要添加 headerLinks,代码是
headerLinks: [
{ doc: "introduction", label: "Docs" },
{ doc: "faq", label: "FAQ" },
{
href: "https://github.com",
label: "Github",
},
{
href: "https://example.com",
label: "Hire Us",
},
Run Code Online (Sandbox Code Playgroud)
我想在“雇用我们”内容之前添加一个图标。我应该写什么?
我想更改 docusaurus 中的侧边栏宽度,我只允许更改特定页面中侧边栏的宽度。任何人都可以建议我解决方案吗
我在工作中有一个任务,是在 Docusaurus 内部实现登录页面。我正在尝试通过添加一些来自
定义. 包括 具有实际 Docusaurus 索引页面的内容index.jsHelloWorldlogin.js
const Index = require('./login.js');
const React = require('react');
class Button extends React.Component {
render() {
return ("helloworld");}
}
module.exports = Button;
Run Code Online (Sandbox Code Playgroud)
但抛出的错误是:
Error: Cannot find module './login.js'
js是否可以从Docusaurus 的另一个页面调用该类?
在 Docusaurus V2 中如何链接到静态文件夹中的 JSON 文件?
我在 markdown 文件中尝试了以下操作:
An exemple, is the following [JSON dataset](../../static/data/solar-radiation.json).
Run Code Online (Sandbox Code Playgroud)
但 Docusaurus 随后会产生以下错误:
./static/data/solar-radiation.json (./node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[hash].[ext]!./static/data/solar-radiation.json)
Module parse failed: Unexpected token e in JSON at position 0 while parsing near 'export default __web...'
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
SyntaxError: Unexpected token e in JSON at position 0 while parsing near 'export default __web...'
at JSON.parse (<anonymous>)
Run Code Online (Sandbox Code Playgroud)
我的文件是有效的 JSON。由于某种原因,Docusaurus 似乎没有显示静态文件,而是尝试解析它......
当我输入时,yarn start我myproject.github.io/websites收到此错误:
yarn run v1.22.11
warning package.json: No license field
$ docusaurus-start
'docusaurus-start' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Run Code Online (Sandbox Code Playgroud)
当我这样做时,yarn global list我得到这个:
yarn global v1.22.11
warning package.json: No license field
info "docusaurus-init@1.14.7" has binaries:
- docusaurus-init
Done in 0.10s.
Run Code Online (Sandbox Code Playgroud)
因此,在我看来,Docusarus 确实已安装,但我无法用它做任何事情。有任何想法吗?
如何让我的 docusaurus 页面以默认的深色模式而不是默认的浅色模式启动?谢谢。
我有一个生成的索引页面,我可以看到如何在目录的类别.json中自定义页面标题和描述,但是有没有办法自定义同一目录中的文件生成的项目?例如:
我希望能够为每个文件提供一个图标,并且与从这些文件中提取的文本不同的文本第一段似乎是默认的。我想要的也许看起来像这个页面,但图标和文本需要链接到教程页面。
我尝试过使用 DocCardList、添加描述、添加项目(失败)以及更改我的每个教程文件,但到目前为止,还没有任何进展。
在我的文档网站的 doc/*.md 页面之一上,我希望能够拥有一个 javascript 树视图。https://github.com/storybookjs/react-treebeard 似乎运行良好,但我并不完全清楚如何将此 javascript 合并到一个特定页面中。
我尝试将示例 javascript 从快速入门部分复制到特定的 *.md 文件中的<script></script>标记中,但在 JS 控制台中出现“语法错误:无法在模块外使用导入语句”错误。
然后我从 *.md 文件中取出导入并将它们放在 website/siteConfig.js 的顶部:
import React, {PureComponent} from 'react';
import ReactDOM from 'react-dom';
import {Treebeard} from 'react-treebeard';
Run Code Online (Sandbox Code Playgroud)
关于我应该在哪里放置这些导入语句的任何想法?