import { api } from "https://esm.town/v/pomdtr/api";
import { parseExample } from "https://esm.town/v/pomdtr/val_town_by_example_parse";
import { blob } from "https://esm.town/v/std/blob";
import { ValTownBlobNotFoundError } from "https://esm.town/v/std/ValTownBlobNotFoundError";
type Dataset = {
title: string;
items: DatasetItem[];
}[];
type DatasetItem = string | {
title: string;
description?: string;
href?: string;
};
function todo(title: string) {
return {
title: `${title}`,
};
}
const dataset: Dataset = [
{
title: "Basics",
items: [
todo("Sharing Code Between Vals"),
"pomdtr/reading_and_writing_blobs",
todo("Storing Secrets in Env Variables"),
todo("Sending Emails"),
],
},
{
title: "SQLite",
items: [
todo("Creating and Deleting Tables"),
todo("Inserting and Querying Data"),
todo("Running Migrations"),
todo("SQLite as a KV Database"),
todo("Drizzle in Val Town"),
],
},
{
title: "Middlewares",
items: [
"pomdtr/password_auth_example",
todo("Email Authentication"),
todo("Code on Val Town Banner"),
],
},
{
title: "HTTP",
items: [
todo("Routing request with Hono"),
todo("Saving HTML Form Data"),
"iamseeley/multirouteHTML",
todo("Rendering JSX"),
todo("Rendering Markdown"),
todo("Creating a Discord Webhook"),
todo("Scrapping Website Data"),
],
},
{
title: "Client-Side",
items: [
"pomdtr/react_example",
todo("Val Town Islands"),
todo("Creating Web Component"),
todo("Embedding Vals in Other Sites"),
],
},
{
title: "Tooling",
items: [
todo("Running Tests on Val.Town"),
todo("Installing Apps on Val Town"),
todo("Querying all Public Vals"),
],
},
];
export type TocItem = {
title: string;
description: string;
href?: string;
};
export type TocGroup = {
title: string;
items: TocItem[];
};
export type Toc = TocGroup[];
const blobKey = "val_town_by_example_toc.json";
export default async function refreshToc() {
const toc: Toc = [];
for (const item of dataset) {