1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
122123export default codeOnValTownBanner(
124passwordAuth(app.fetch, { verifyPassword: verifyToken }),
125);
knowledgeExplorermain.tsx10 matches
17const [activeButton, setActiveButton] = useState(null);
1819const fetchContent = useCallback(async (prompt, direction) => {
20setLoading(true);
21try {
22const response = await fetch("/generate", {
23method: "POST",
24headers: { "Content-Type": "application/json" },
30setContent(newContent);
31} catch (error) {
32console.error("Error fetching content:", error);
33setContent("An error occurred while fetching content.");
34}
35setLoading(false);
39e.preventDefault();
40if (topic) {
41fetchContent(`Provide a concise overview of ${topic} in about 3-4 sentences. Focus on key points and interesting facts. Format your response as follows:
42Title: [A short, catchy title for the topic]
4352setActiveButton("right");
53setTimeout(() => setActiveButton(null), 300);
54fetchContent(`Based on the topic "${title}" and the following information: "${content}", explore a semantically related topic. Provide a brief overview of this new topic, highlighting its connection to ${title}. Format your response as follows:
55Title: [A short, catchy title for the new related topic]
5659setActiveButton("down");
60setTimeout(() => setActiveButton(null), 300);
61fetchContent(`Given the overview of ${title}: "${content}", choose a directly related subtopic or aspect of ${title}. Provide a detailed explanation of this subtopic, focusing on its significance and relationship to the main topic. Format your response as follows:
62Title: [A short, catchy title for the subtopic]
6365}
66}
67}, [fetchContent, title, content]);
6869useEffect(() => {
110🏠 Home
111</button>
112<button className={`right-button ${activeButton === 'right' ? 'active' : ''}`} onClick={() => fetchContent(`Based on the topic "${title}" and the following information: "${content}", explore a semantically related topic. Provide a brief overview of this new topic, highlighting its connection to ${title}. Format your response as follows:
113Title: [A short, catchy title for the new related topic]
114116➡️ Related Topic
117</button>
118<button className={`down-button ${activeButton === 'down' ? 'active' : ''}`} onClick={() => fetchContent(`Given the overview of ${title}: "${content}", choose a directly related subtopic or aspect of ${title}. Provide a detailed explanation of this subtopic, focusing on its significance and relationship to the main topic. Format your response as follows:
119Title: [A short, catchy title for the subtopic]
120
1/** @jsxImportSource npm:hono@3/jsx */
2import { modifyFetchHandler as codeOnValTownBanner } from "https://esm.town/v/andreterron/codeOnValTown";
3import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
4import { Hono } from "npm:hono@3";
122123export default codeOnValTownBanner(
124passwordAuth(app.fetch, { verifyPassword: verifyToken }),
125);
outsideBlushShrimpmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
52}
5354export default modifyFetchHandler;
outsideBlushShrimpREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These 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:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
crazyPeachCrayfishREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These 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:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
crazyPeachCrayfishmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style }: { val?: ValRef; style?: string } = {},
52}
5354export default modifyFetchHandler;
codeOnValTownREADME.md6 matches
11Here are 2 different ways to add the "Code on Val Town" ribbon:
1213### 1. Wrap your fetch handler (recommended)
1415```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
1819export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20return html(`<h2>Hello world!</h2>`);
21});
51These 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:
5253- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
5558You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
5960- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
626465```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67.github-fork-ribbon {
68display: none !important;
codeOnValTownmain.tsx3 matches
3738/**
39* @param handler Fetch handler
40* @param val Define which val should open
41*/
42export function modifyFetchHandler(
43handler: (req: Request) => Response | Promise<Response>,
44{ val, style }: { val?: ValRef; style?: string } = {},
52}
5354export default modifyFetchHandler;
emperorOfJapanCrawlermain.tsx2 matches
1// This program crawls Wikipedia pages starting from an initial URL,
2// following links in the infobox and collecting page titles.
3// It uses the fetch API to make HTTP requests and cheerio for HTML parsing.
45import cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
12visited.add(url);
1314const response = await fetch(url);
15const html = await response.text();
16const $ = cheerio.load(html);