-
|
I have a page that all cards' data is generated by a 'db.toml' file . |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
You can only import Node.js APIs like fs in Node.js files. You can't use Node.js APIs in React components, but you can use Node.js APIs in plugins and watch files to reload plugin data and re-render the UI. Your page looks a bit like our site showcase, for which we have an internal plugin that we are likely to make an official first-party plugin in the future (#9967). This can serve as an inspiration to implement your plugin. It's outside the scope of Docusaurus to expose an API to let you edit the local toml file, but you can implement this yourself as a separate Node.js server API outside of Docusaurus. If you write to the file and implement a Docusaurus plugin to read it, your page will hot reload whenever you write it. In the future, we want to support React Server Components (#9089) running at build time and letting you access Node.js APIs directly in React components. |
Beta Was this translation helpful? Give feedback.
You can only import Node.js APIs like fs in Node.js files. You can't use Node.js APIs in React components, but you can use Node.js APIs in plugins and watch files to reload plugin data and re-render the UI.
Your page looks a bit like our site showcase, for which we have an internal plugin that we are likely to make an official first-party plugin in the future (#9967). This can serve as an inspiration to implement your plugin.
It's outside the scope of Docusaurus to expose an API to let you edit the local toml file, but you can implement this yourself as a separate Node.js server API outside of Docusaurus. If you write to the file and implement a Docusaurus plugin to read it, your page wil…