nbbaier avatar
cronLogger
@nbbaier
Script
Log your cron evaluations to sqlite import { cronEvalLogger as logger } from "https://esm.town/v/nbbaier/cronLogger"; const run = async (interval: Interval) => { console.log("your code goes here"); }; export default logger(run);
stevekrouse avatar
grantParentReference
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
whoami
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
stevekrouse avatar
open_in_valtown
@stevekrouse
Script
* @param handler Fetch handler
stevekrouse avatar
refsExample
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
pomdtr avatar
serve_readme
@pomdtr
Script
Serve Readme Usage import codeOnValTown from "https://esm.town/v/andreterron/codeOnValTown?v=50"; import { serveReadme } from "https://esm.town/v/pomdtr/serve_readme"; const val = extractValInfo(import.meta.url); export default serveReadme({ val, title: "Code Search is Easy", }); Example @pomdtr/code_search_is_easy (rendered at https://code-search-is-easy.pomdtr.me )
stevekrouse avatar
parentReference
@stevekrouse
Script
An interactive, runnable TypeScript val by stevekrouse
andreterron avatar
inferRequestVal
@andreterron
Script
An interactive, runnable TypeScript val by andreterron
pomdtr avatar
article
@pomdtr
HTTP
Use readme as website Usage import {article} from "https://esm.town/v/pomdtr/article" export default article() See this val http endpoint as an example: https://pomdtr-article.web.val.run
neverstew avatar
cronEvalLogger
@neverstew
Script
Log your cron evaluations to sqlite import { cronEvalLogger } from "https://esm.town/v/neverstew/cronEvalLogger"; const yourCron = async (interval: Interval) => { console.log("your code goes here"); }; export default cronEvalLogger(yourCron);
pomdtr avatar
refs
@pomdtr
Script
An interactive, runnable TypeScript val by pomdtr
andreterron avatar
codeOnValTown
@andreterron
Script
Code on Val Town Adds a "Code on Val Town" ribbon to your page. This lets your website visitors navigate to the code behind it. This uses github-fork-ribbon-css under the hood. Usage Here are 2 different ways to add the "Code on Val Town" ribbon: 1. Wrap your fetch handler (recommended) import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=45"; import { html } from "https://esm.town/v/stevekrouse/html?v=5"; export default modifyFetchHandler(async (req: Request): Promise<Response> => { return html(`<h2>Hello world!</h2>`); }); Example: @andreterron/openable_handler 2. Wrap your HTML string import { modifyHtmlString } from "https://esm.town/v/andreterron/codeOnValTown?v=45"; import { html } from "https://esm.town/v/stevekrouse/html?v=5"; export default async (req: Request): Promise<Response> => { return html(modifyHtmlString(`<h2>Hello world!</h2>`)); }; Example: @andreterron/openable_html Other ways We made sure this was very modular, so you can also add the ribbon using these methods: Get the element string directly: @andreterron/codeOnVT_ribbonElement Modify an HTTP Response: @andreterron/codeOnVT_modifyResponse Use .pipeThrough to append to a stream: @andreterron/InjectCodeOnValTownStream Customization Linking to the val These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the val argument: modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }}) modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }}) Styling You can set the style parameter to a css string to customize the ribbon. Check out github-fork-ribbon-css to learn more about how to style the element. modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"}) modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"}) Here's how you can hide the ribbon on small screens: modifyFetchHandler(handler, {style: `@media (max-width: 768px) { .github-fork-ribbon { display: none !important; } }`}) To-dos [ ] Let users customize the ribbon. Some ideas are the text, color or placement.
stevekrouse avatar
untitled_limeBeetle
@stevekrouse
Script
// console.log(import.meta, getMeta());
stevekrouse avatar
editRedirect
@stevekrouse
Script
Redirect to Val Page Redirect from web val to val page by adding /edit to the URL. Convention by pomdtr . Usage import { editRedirect } from "https://esm.town/v/stevekrouse/editRedirect"; import { Hono } from "npm:hono@3"; const app = new Hono(); app.get("/", (c) => c.text("Hello world!")); app.get("/edit", (c) => editRedirect()); export default app.fetch; TODO [ ] turn this into middleware in the style of @pomdtr/basicAuth Live: https://stevekrouse-edit_redirect_example.web.val.run/edit
stevekrouse avatar
ssr_react_mini
@stevekrouse
Script
Server-side Render React Mini Framework This is very experimental, more of a prototype of an architecture, than a true framework Example: https://www.val.town/v/stevekrouse/TodoApp
1
Next
v11
October 24, 2023