8
9```ts
10export default function() {
11 <h1>Hello World!</h1>
12}
15Optionally, you can define an handler next to your component, allowing you to handle query params or form inputs.
16
17Use the `ctx.render` function to pass props to your component.
18
19```ts
24};
25
26export default function(props: {name?: string}) {
27 <h1>Hello { name || "World }!</h1>
28}
1# valToGH
2
3A utility function for programmatically updating a GitHub repository with code retrieved from a Val.
4
5**NOTE**: This function currently does not change the contents of a file if it is already present. I will however be adding that functionality.
6
7## Usage
1export default function(req) {
2 return new Response("dev");
3}
2import { fetch } from "https://esm.town/v/std/fetch";
3
4async function getOfficialRedditPosts() {
5 const resp = await fetch("https://www.reddit.com/r/googlephotos/.json");
6 if (!resp.ok) return [];
12 return filtered_posts;
13}
14async function getGoogleSupportForumPosts() {
15 const resp = await fetch(
16 "https://support.google.com/photos/threads?hl=en&max_results=500",
1import { sqlite } from "https://esm.town/v/std/sqlite";
2
3export default async function() {
4 return sqlite.execute(`CREATE TABLE IF NOT EXISTS todos (
5 id INTEGER PRIMARY KEY AUTOINCREMENT,
5 * @param handler Fetch handler
6 */
7export default function openInValTown(
8 handler: (req: Request) => Promise<Response>,
9): (req: Request) => Promise<Response> {
1export const MAX_VAL_SIZE = 10_000_000
2
3export function maxSizeOrError(data) {
4 const string = JSON.stringify(data)
5 if (string.length > MAX_VAL_SIZE) {
1console.log("resizing script loaded!");
2if (typeof Deno === "undefined") {
3 const resizable = function(resizer) {
4 const direction = resizer.getAttribute("data-direction") || "horizontal";
5 const prevSibling = resizer.previousElementSibling;
11 let prevSiblingWidth = 0;
12
13 const mouseDownHandler = function(e) {
14 const parent = e.currentTarget.parentElement;
15 const direction = parent.getAttribute("data-direction") || "horizontal";
27 };
28
29 const mouseMoveHandler = function(e) {
30 const dx = e.clientX - x;
31 const dy = e.clientY - y;
56 };
57
58 const mouseUpHandler = function() {
59 resizer.style.removeProperty("cursor");
60 document.body.style.removeProperty("cursor");
75 };
76
77 document.querySelectorAll(".resizer").forEach(function(ele) {
78 resizable(ele);
79 });
2import { Feed, FeedOptions, Item as FeedItem } from "npm:feed";
3
4export async function flydotioRSS(req: Request): Promise<Response> {
5 const response = await fetch("https://fly.io/blog/");
6 const body = await response.text();
24const prompts = classes.map(c => `${storyboardPreface} ${c[1]}`);
25
26export default async function(req: Request): Promise<Response> {
27 if (req.method === "GET") {
28 return Response.json({ nada: true });
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.