[v2] Support javascript src files (among others) in multi-version mode
See original GitHub issue🚀 Feature
Hey there! We’re in the process of setting up Docusaurus v2 at Rasa and we’ve hit a roadblock. The basic use case is the following:
- we want to build variables (from the code, code is in python) and include them in the doc
- we want to require source files from the doc
Everything works fine until multi-version kicks in. For 1., we initially built variables into a JS file under the src/
folder, but realised that the src/
folder was shared across versions of the docs. The same applies to 2. (nothing seems to be copied inside the different versions).
Here is how we implemented it:
- add a pre-build step (before calling
docusaurus build
ordocusaurus start
) - this pre-build step generates files under the
docs/sources/
folder; this allows to support multiple versions (everything underdocs/
seems to be copied to versions)
This use case doesn’t seem too exotic, wondering if this is something you planned to support and/or if there is an undocumented way of doing that.
Have you read the Contributing Guidelines on issues?
yes
Motivation
We’re moving from Sphinx to Docusaurus (v2).
Pitch
⬆️ See above 🙃
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Can I use multiple versions of jQuery on the same page?
Yes, it's doable due to jQuery's noconflict mode. http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/
Read more >Debug Node.js Apps using Visual Studio Code
The Visual Studio Code editor includes Node.js debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >Documentation - Migrating from JavaScript - TypeScript
js files are in a src , lib , or dist directory, and then ran as desired. If that's the case, the files...
Read more >JavaScript modules - MDN Web Docs
Node.js has had this ability for a long time, and there are a number of JavaScript libraries and frameworks that enable module usage...
Read more >RequireJS API
Loading Modules from Packages§ 4.1; Multiversion Support§ 4.2 ... ID of 'main'--> <script data-main="scripts/main.js" src="scripts/require.js"></script>.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes that seems appropriate even if I don’t understand everything ^^ anything in /docs will be versioned, everything outside will not
Thanks for pointing that out @slorber. If you feel that we’re using Docusaurus v2 as intended, then we’re good 👍
For reference, here is an example of our folder structure:
Everything under
sources/
+ thevariables.json
is generated outside of the docusaurus build system and gitignored. We have custom plugins to include them in the docs. When we cut a new version, we assume that everything underdocs/
is moved to a new version folder (and it seems to work).The
variables.json
looks like this:and is version-dependant.