-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v2): debug pages + debug layout + ability to debug content (#3229)
* improve debug plugin: - add multiple debug pages + debug layout - ability to debug plugin contentLoaded data * add missing dependency * fix broken test * improve content rendering a bit * create basic DebugJsonView * fix ReactJson SSR issues
- Loading branch information
Showing
30 changed files
with
511 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
packages/docusaurus-plugin-debug/src/theme/DebugConfig/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import DebugLayout from '../DebugLayout'; | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
|
||
function DebugMetadata() { | ||
const {siteConfig} = useDocusaurusContext(); | ||
return ( | ||
<DebugLayout> | ||
<h2>Site config</h2> | ||
<div>{JSON.stringify(siteConfig, null, 2)}</div> | ||
</DebugLayout> | ||
); | ||
} | ||
|
||
export default DebugMetadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/docusaurus-plugin-debug/src/theme/DebugContent/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React, {useState} from 'react'; | ||
|
||
import DebugLayout from '../DebugLayout'; | ||
import DebugJsonView from '../DebugJsonView'; | ||
|
||
const PluginInstanceContent = ({pluginId, pluginInstanceContent}) => ( | ||
<section style={{marginBottom: 30}}> | ||
<h4>{`>> ${pluginId}`}</h4> | ||
<div | ||
style={{ | ||
marginTop: 10, | ||
padding: 10, | ||
border: 'thin cyan solid', | ||
borderRadius: 5, | ||
backgroundColor: 'lightgrey', | ||
}}> | ||
<DebugJsonView src={pluginInstanceContent} /> | ||
</div> | ||
</section> | ||
); | ||
|
||
const PluginContent = ({pluginName, pluginContent}) => { | ||
const [visible, setVisible] = useState(true); | ||
return ( | ||
<section style={{marginBottom: 60}}> | ||
<h3 onClick={() => setVisible((v) => !v)} style={{cursor: 'pointer'}}> | ||
{pluginName} | ||
</h3> | ||
{visible && ( | ||
<div> | ||
{Object.entries(pluginContent) | ||
// filter plugin instances with no content | ||
.filter( | ||
([_pluginId, pluginInstanceContent]) => !!pluginInstanceContent, | ||
) | ||
.map(([pluginId, pluginInstanceContent]) => { | ||
return ( | ||
<PluginInstanceContent | ||
key={pluginId} | ||
pluginId={pluginId} | ||
pluginInstanceContent={pluginInstanceContent} | ||
/> | ||
); | ||
})} | ||
</div> | ||
)} | ||
</section> | ||
); | ||
}; | ||
|
||
function DebugContent({allContent}) { | ||
return ( | ||
<DebugLayout> | ||
<h2>Plugin content</h2> | ||
<div> | ||
{Object.entries(allContent) | ||
// filter plugins with no content | ||
.filter(([_pluginName, pluginContent]) => | ||
Object.values(pluginContent).some( | ||
(instanceContent) => !!instanceContent, | ||
), | ||
) | ||
.map(([pluginName, pluginContent]) => { | ||
return ( | ||
<PluginContent | ||
key={pluginName} | ||
pluginName={pluginName} | ||
pluginContent={pluginContent} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</DebugLayout> | ||
); | ||
} | ||
|
||
export default DebugContent; |
7 changes: 7 additions & 0 deletions
7
packages/docusaurus-plugin-debug/src/theme/DebugContent/styles.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
Oops, something went wrong.