Allow a single docs folder to be consumed by 2 docs plugin instances (use-case: normal vs embed/iframe docs)
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn clear
command. - I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
If I add the docs plugin to the list of plugins (multi-instance) and I point it to the same folder that the preset is already pointing to (docs
by default), the build process stops working and I see the following errors:
SyntaxError: /code/src/......../index.mdx: Identifier 'React' has already been declared. (46:184)
I believe the bug might be caused by the way each mdx file is being processed. Because a mdx file is (basically) a JSX file, import React from 'react';
is being prepended at the top of each file. But since I have two instances of the docs plugin pointing to the same folder, the import
statement is being prepended twice (hence the error).
I made a minimal repro codesandbox.
Reproducible demo
https://codesandbox.io/s/trusting-rosalind-sc4s15
Steps to reproduce
- Open the link
- Open a new tty and type
npm run build
- The build will fail.
- Comment the
plugins
section of thedocusaurus.config.js
- Run
npm run build
again. - The build will succeed.
Expected behavior
I should be able to point multiple instances of the docs plugin to the same folder.
Actual behavior
The build crashes.
Your environment
- Public source code: N/A
- Public site URL: N/A
- Docusaurus version used: 2.0.0-beta20
- Environment name and version (e.g. Chrome 89, Node.js 16.4): N/A
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): N/A
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Single sign-on (SSO) embedding | Looker - Google Cloud
Single sign-on (SSO) embedding is a way to present private embedded Looks, visualizations, Explores, dashboards, or LookML dashboards to your users without ...
Read more >TechDocs How-To guides - Backstage.io
TechDocs How-To guides · 1. Prepare a cloud storage · 2. Publish to storage from CI/CD · 3. Switch TechDocs to read-only mode...
Read more >Make Google Docs, Sheets, Slides & Forms public
Embed files. You can make a document, spreadsheet, presentation, or form available to view on an existing website by embedding it in your...
Read more >Access documents and other files from shared storage
Use cases for accessing documents and other files; Create a new file; Open a file ... allowing them to browse a documents provider...
Read more >Best practices for React iframes - LogRocket Blog
Explore two use cases for React iframes, embedding external content ... For one, src is used to set the address of the webpage...
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
I have a product with a lot of “elements” (think about it as if the product was a 3D viewer of a car and each element a piece of that car). I want to point users to the documentation site and let them read the entire doc, but I’d also like to be able to show the particular documentation page for each piece.
When each element is clicked a modal window (containing several config options) is shown. Embedding the docs inside an iframe in a tab in that modal window sounds like a reasonably good idea to me.
Each “piece” will have it’s own document page, so I’d show only that particular doc page.
No, none of this is publicly available 😦
Not at all. That would be an iframe, so the url doesn’t really matter.
Hmmm 🤔 haven’t really thought about that. Maybe go to whatever link the user clicked, but the “embedded” version?
Indeed. Maybe all of this could be avoided by implementing #5046
That really sounds like a hacky solution, not my style I’m afraid.
That is theoretically possible, but I’ll have hundreds of “pieces”, which means hundreds of “doc pages”. I’m afraid that will grow up to “unmanageable” really fast.
I’d rather just copy (on build time) the entire “docs” folder and do it with 2 instances of the docs plugin.
I don’t really know. I don’t think it’s possible with today’s setup, which is why I’m still leaving it open 😃 But it’s definitely legitimate and we’ll figure out a way to do it. Sorry if you think it’s going to be a quick little bug fix—it’s probably more complicated than we have thought.
@slorber will be back tomorrow, and maybe he can have some opinions to offer as well.