Skip to content

Commit 9fc6fee

Browse files
updates
1 parent 49b277e commit 9fc6fee

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/documentation/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,22 @@ fs.writeFileSync(
778778
JS.replace('\'PUBLICOUTPUT\'', publicOutput).replace('let searchurl = "/_just/search";', `let searchurl = "/_just/${dataname[9]}.json";`),
779779
template.charset
780780
);
781+
const fetchjson = async (protocol) => {
782+
const response1 = await fetch(`${protocol}://${domain}/_just/`);
783+
const data1 = await response1.json();
784+
const response2 = await fetch(`${protocol}://${domain}/_just/${data1.json}.json`);
785+
const data2 = await response2.json();
786+
fs.writeFileSync(path.join(websitepath, '_just', `${data1.json}.json`), JSON.stringify(data2));
787+
}
788+
if (domain) {
789+
try {
790+
await fetchjson('http')
791+
} catch (ee) {
792+
try {
793+
await fetchjson('https')
794+
} catch (e_e) {}
795+
}
796+
}
781797
fs.writeFileSync(path.join(websitepath, '_just', `${dataname[9]}.json`), JSON.stringify(mdjson), template.charset);
782798
fs.writeFileSync(path.join(websitepath, '_just', 'index.json'), JSON.stringify({
783799
"js": filename.js,

src/documentation/templates/page.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,29 +272,16 @@ document.addEventListener('DOMContentLoaded', () => {
272272
updateSD(st);
273273
const pta = '<br>Please try again';
274274
if (st) {
275-
let response = await fetch(searchurl).catch((err__)=>{
275+
const response = await fetch(searchurl).catch((err__)=>{
276276
console.warn(err__);
277277
sd.innerHTML = `<span>Failed to fetch.${pta}</span>`;
278278
return
279279
});
280-
let data = await response.json().catch((err__)=>{
280+
const data = await response.json().catch((err__)=>{
281281
console.warn(err__);
282282
sd.innerHTML = `<span>Something went wrong.${pta}</span>`;
283283
return
284284
});
285-
if (data.json) {
286-
searchurl = data.json;
287-
response = await fetch(searchurl).catch((err__)=>{
288-
console.warn(err__);
289-
sd.innerHTML = `<span>Failed to fetch.${pta}</span>`;
290-
return
291-
});
292-
data = await response.json().catch((err__)=>{
293-
console.warn(err__);
294-
sd.innerHTML = `<span>Something went wrong.${pta}</span>`;
295-
return
296-
});
297-
}
298285
const searchdata = search2(data, sv);
299286
if (searchdata.length == 0) {
300287
sd.innerHTML = '<span>Nothing found.</span>';

0 commit comments

Comments
 (0)