Skip to content

Commit

Permalink
Support variable locations for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
brockfanning committed May 27, 2024
1 parent 38a045b commit 423e45a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ import GroupWithAccordion, {

const App = () => {

const fetchDocumentation = () => {
fetch("https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/configuration/")
.then(response => {
return response.json()
})
.then(data => {
setDocumentation(data);
});
const fetchDocumentation = (configType) => {
if (configType === 'metadata') {
return;
}
let docs = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/configuration/';
if (configType === 'indicator') {
docs = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/indicator-configuration/';
}
fetch(docs)
.then(response => {
return response.json()
})
.then(data => {
setDocumentation(data);
});
}

const setDocumentation = (data) => {
Expand Down Expand Up @@ -122,13 +129,14 @@ const App = () => {
githubOwner,
repoUrl,
repositoryLink,
configType,
} = opensdg.configForm;
const [formData, setFormData] = useState(initialData);
const [formErrors, setFormErrors] = useState(null);
const jsonformsConfig = {
showUnfocusedDescription: true,
};
setTimeout(fetchDocumentation, 2000);
setTimeout(fetchDocumentation.bind(null, configType), 2000);
return (
<>
<SearchBar
Expand Down

0 comments on commit 423e45a

Please sign in to comment.