initial public commit
This commit is contained in:
36
public/demo/overview-example-result.js
Normal file
36
public/demo/overview-example-result.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { loadAndParseTwtxtFile } from "/dist-browser/twtxt-lib.js";
|
||||
|
||||
// run in an IIFE (or event listener) to avoid issues with top-level await
|
||||
(async () => {
|
||||
try {
|
||||
const parsedFile = await loadAndParseTwtxtFile(
|
||||
"/twtxt-demos/demo-hipster-twtxt.txt",
|
||||
);
|
||||
|
||||
console.log(parsedFile);
|
||||
|
||||
document.getElementById("tabOverview-example")?.insertAdjacentHTML(
|
||||
"beforeend",
|
||||
`
|
||||
<details open="true">
|
||||
<summary>Result</summary>
|
||||
<figure>
|
||||
<pre id="preResult">${JSON.stringify(
|
||||
parsedFile,
|
||||
null,
|
||||
2,
|
||||
).replace(
|
||||
// to color properties
|
||||
/"\w+":/g,
|
||||
(val) => `<span class="code-str">${val}</span>`,
|
||||
)}</pre>
|
||||
</figure>
|
||||
</details>
|
||||
`,
|
||||
);
|
||||
|
||||
document.body.classList.add("isLoaded");
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user