Back

Version 64

2/1/2024
// this is running from the browser, so we cannot use `npm:js-base64`
import { Base64 } from "https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.mjs";
import { BrowserContext } from "https://esm.town/v/pomdtr/browser";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";

export default async function(ctx: BrowserContext) {
const { author, name } = extractValInfo(ctx.url);
const title = `@${author}/${name}`;
const { code } = await ctx.api(`https://api.val.town/v1/alias/${author}/${name}`);

const hash = `#language=tsx&title=${title}&code=${Base64.encodeURI(code)}`;
window.open(`https://ray.so${hash}`, "_blank");
}

// #web
Updated: February 13, 2024