@ -4,20 +4,20 @@
import Layout from '$/client/Layout.svelte';
import Icon from '$/client/components/Icon.svelte';
import Code from "$/client/components/Code.svelte";
import HTML from "$/client/components/HTML.svelte";
import api from "$/client/api.js";
let index = {} ;
let docs_data;
let url;
let readme_docs;
let url = "/docs/";
export let params;
const caps_to_icon = {
"_ BUG_ ": "bug",
"_ TODO_ ": "clipboard-check",
"_ WARNING_ ": "alert-triangle",
"_ FOOTGUN_ ": "bomb",
"_ DEPRECATED_ ": "axe"
"BUG": "bug",
"TODO": "clipboard-check",
"WARNING": "alert-triangle",
"FOOTGUN": "bomb",
"DEPRECATED": "axe"
}
const jump = (id) => {
@ -25,9 +25,7 @@
if(node) node.scrollIntoView();
}
const jump_top = () => {
jump("top-scroll");
}
const jump_top = () => jump("top-scroll");
const load_docs = async (to_load) => {
// only load if the URL changed
@ -42,26 +40,9 @@
const load_index = async () => {
const [status, data] = await api.get("/docs/api/index.json");
index = status === 200 ? data : {} ;
}
const load_readme = async () => {
if(!readme_docs) {
console.log("LOAD README");
const [status, data] = await api.blob("/docs/api/index.html");
if(status === 200) {
readme_docs = await data.text();
} else {
readme_docs = `< callout class = "error" > ERROR LOADING README: ${ status } </ callout > `
}
}
url = "/docs/";
console.log("URL", url, "README", readme_docs !== undefined, "PARAMS", params);
}
const type_to_syntax = {
"callexpression": "()",
"objectexpression": "{} ",
@ -70,17 +51,13 @@
"method": "()"
}
onMount(async () => {
await load_readme();
await load_index();
});
onMount(load_index);
$: if(params.wild) {
// load_docs will ignore any calls where params.wild doesn't change url
load_docs(params.wild)
url = url; // the most irritating thing about Svelte
} else {
load_readme();
url = url;
url = "/docs/";
}
< / script >
@ -206,7 +183,7 @@
< sidebar >
< top > < h4 > < a href = "/" use:link > < Icon name = "arrow-left-circle" / > API Docs< / a > < / h4 > < / top >
< items >
< a class:active = { url === "/docs/" } href="/docs/" use:link > README </ a >
< a class:active = { url === "/docs/" } href="/docs/" use:link > Introduction </ a >
{ #each Object . keys ( index ) as item }
< a class:active = { item === url } href="/docs/ { item } " use:link > { item } </ a >
{ /each }
@ -216,9 +193,7 @@
< right >
{ #if url === "/docs/" }
< div id = "top-scroll" >
{ #if readme_docs }
{ @html readme_docs }
{ /if }
< HTML url = "/docs/api/index.html" / >
< / div >
{ :else if docs_data }
< toc id = "top-scroll" >