Public
Back

Version 52

3/21/2024
/** @jsxImportSource https://esm.sh/preact **/

import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
import { api } from "https://esm.town/v/pomdtr/api";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { gfm } from "https://esm.town/v/pomdtr/gfm";
import { compile } from "npm:@mdx-js/mdx";
import { render } from "npm:preact-render-to-string";

const css = `
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}

@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
`;

export function mdx(author: string, name: string) {
return async (req: Request) => {
const { readme } = await api(`/v1/alias/${author}/${name}`);
const vfile = await compile(readme, {
jsxImportSource: "https://esm.sh/preact",
});

const url = new URL(req.url);
if (url.pathname == "/mod.js") {
return new Response(vfile.toString(), {
headers: {
pomdtr-mdx.web.val.run
Updated: December 13, 2024