40});
41
42export default liveReload(app.fetch, import.meta.url);
93}
94/**
95 * Creates a wrapper around a fetch handler that injects an HTML string
96 * into the document. It first checks for a <body> tag; if missing,
97 * it looks for an <html> tag. If neither are present, it appends to
98 * the full text response.
99 *
100 * @param handler The original fetch handler function
101 * @param html The HTML content to inject
102 * @returns A new fetch handler with HTML rewriting
103 */
104export function injectHTML(
20import { liveReload } from "https://esm.town/v/stevekrouse/live-reload/main.ts";
21
22const handler = (req: Request) => { /* your fetch handler */}
23export default liveReload(handler, import.meta.url);
24```
59
60// Enable live reloading
61export default liveReload(app.fetch, import.meta.url);
62```
63
7 return new Response(`Learn more at https://www.val.town/x/stevekrouse/live-reload`);
8 }
9 const resp = await fetch(targetURL, {
10 headers: req.headers,
11 });
6 */
7async function registerLongPoll({ pageLoadedAt }: { pageLoadedAt: number }) {
8 const { lastUpdatedAt, status } = await (await fetch("/__lastUpdatedAt")).json();
9 if (lastUpdatedAt > pageLoadedAt) {
10 window.location.href = `https://reload.val.run?${new URLSearchParams({ url: window.location.href })}`;
28 return;
29 }
30 const resp = await fetch(targetURL);
31 if (resp.ok) {
32 window.location.href = targetURL;
72const app = new Hono();
73app.get("/", about);
74export default app.fetch;
93}
94/**
95 * Creates a wrapper around a fetch handler that injects an HTML string
96 * into the document. It first checks for a <body> tag; if missing,
97 * it looks for an <html> tag. If neither are present, it appends to
98 * the full text response.
99 *
100 * @param handler The original fetch handler function
101 * @param html The HTML content to inject
102 * @returns A new fetch handler with HTML rewriting
103 */
104export function injectHTML(
20import { liveReload } from "https://esm.town/v/stevekrouse/live-reload/main.ts";
21
22const handler = (req: Request) => { /* your fetch handler */}
23export default liveReload(handler, import.meta.url);
24```
59
60// Enable live reloading
61export default liveReload(app.fetch, import.meta.url);
62```
63
7 return new Response(`Learn more at https://www.val.town/x/stevekrouse/live-reload`);
8 }
9 const resp = await fetch(targetURL, {
10 headers: req.headers,
11 });
6 */
7async function registerLongPoll({ pageLoadedAt }: { pageLoadedAt: number }) {
8 const { lastUpdatedAt, status } = await (await fetch("/__lastUpdatedAt")).json();
9 if (lastUpdatedAt > pageLoadedAt) {
10 window.location.href = `https://reload.val.run?${new URLSearchParams({ url: window.location.href })}`;
28 return;
29 }
30 const resp = await fetch(targetURL);
31 if (resp.ok) {
32 window.location.href = targetURL;