Skip to content

Commit

Permalink
Merge pull request #475 from open-rpc/fix/docs-build
Browse files Browse the repository at this point in the history
fix: docs build issue with monaco
  • Loading branch information
shanejonas authored Jul 21, 2020
2 parents 0de3607 + 033c515 commit 29b870d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions templates/docs/gatsby/src/pages/api-documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import PlaygroundSplitPane from "../components/PlaygroundSplitPane";
const $RefParser = require("json-schema-ref-parser"); //tslint:disable-line
import { useTheme } from "@material-ui/core/styles";
import useInspectorActionStore from "../stores/inspectorActionStore";

import "monaco-editor/esm/vs/language/json/json.worker.js";
import { OpenrpcDocument } from "@open-rpc/meta-schema";

const ApiDocumentation: React.FC = () => {
if (typeof window === "undefined") {
return null;
}
const currentTheme = useTheme();
const [horizontalSplit, setHorizontalSplit] = useState(false);
const [inspectorContents] = useInspectorActionStore();
const [inspectorContents] = useInspectorActionStore<any>();

useEffect(() => {
if (inspectorContents) {
Expand Down Expand Up @@ -56,14 +60,20 @@ const ApiDocumentation: React.FC = () => {
}
}
`);
const [openrpcDocument, setOpenrpcDocument] = useState();
const [openrpcDocument, setOpenrpcDocument] = useState<OpenrpcDocument>();
const [inspectorUrl, setInspectorUrl] = useState<string>();

useEffect(() => {
if (openrpcQueryData.openrpcDocument) {
$RefParser.dereference(JSON.parse(openrpcQueryData.openrpcDocument.openrpcDocument)).then(setOpenrpcDocument);
}
}, [openrpcQueryData])
}, [openrpcQueryData]);

useEffect(() => {
if (openrpcDocument && openrpcDocument.servers && openrpcDocument.servers[0]) {
setInspectorUrl(openrpcDocument.servers[0].url);
}
}, [openrpcDocument])

return (
<PlaygroundSplitPane
Expand All @@ -82,6 +92,7 @@ const ApiDocumentation: React.FC = () => {
}}
right={
<Inspector
url={inspectorUrl}
hideToggleTheme={true}
openrpcDocument={openrpcDocument}
darkMode={darkmode.value}
Expand Down

0 comments on commit 29b870d

Please sign in to comment.