Back

Version 19

3/28/2024
import { rootValRef } from "https://esm.town/v/andreterron/rootValRef?v=3";
import { ValRef } from "https://esm.town/v/andreterron/ValRef?v=1";
import { api } from "https://esm.town/v/pomdtr/api";
import { gfm } from "https://esm.town/v/pomdtr/gfm";
import { html } from "https://esm.town/v/stevekrouse/html?v=5";
import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";

export function article({ val, title }: {
val?: ValRef;
title?: string;
} = {}) {
return async (req: Request) => {
if (!val?.handle && val?.name) {
const { origin } = new URL(req.url);
const subdomain = origin.split(".")[0];
const [handle, name] = subdomain.split("-");
val = { handle, name };
}
if (!title) {
title = `@${val.handle}/${val.name}`;
}
const { code, readme } = await api(`/v1/alias/${val.handle}/${val.name}`);

return html(await gfm(readme, { title, favicon: "📝" }));
};
}

export default article();
pomdtr-article.web.val.run
Updated: May 6, 2024