11}
12
13export default function BulkResults({ cards, totalGenerated, generationTime, mode, onClose }: BulkResultsProps) {
14 const [selectedFormat, setSelectedFormat] = useState<'csv' | 'json' | 'text' | 'list'>('list');
15 const [currentPage, setCurrentPage] = useState(1);
4 * Creates a preview of markdown content by taking first paragraph or truncating
5 */
6export function createPreview(content: string): string {
7 const firstParagraph = content.split("\n\n")[0];
8
17 * Extracts clean post title from filename
18 */
19export function getPostTitle(filename: string): string {
20 return filename.replace(".md", "");
21}
24 * Creates HTML response with proper content type
25 */
26export function createHtmlResponse(html: string): Response {
27 return new Response(html, {
28 headers: { "content-type": "text/html;" },
12 * Loads all blog posts from the posts directory
13 */
14async function loadPosts(): Promise<PostData[]> {
15 const files = await listFiles(import.meta.url);
16 const postFiles = files.filter(file => file.path.startsWith("posts/"));
27 * Renders React component to complete HTML document
28 */
29function renderPage(children: React.ReactNode): Response {
30 const bodyContent = renderToString(<Layout>{children}</Layout>);
31 const html = createHtmlDocument(bodyContent);
36 * Main request handler with routing logic
37 */
38export async function handleRequest(req: Request): Promise<Response> {
39 const { pathname } = new URL(req.url);
40
11 * Homepage component displaying blog header and post previews
12 */
13export function App({ posts }: AppProps) {
14 return (
15 <>
5 * Theme selector dropdown
6 */
7export function ThemeSelector() {
8 return (
9 <select id="theme" className="select select-bordered w-full max-w-xs">
20 * Blog header with title, description and theme selector
21 */
22export function BlogHeader() {
23 return (
24 <div className="text-center space-y-4">
38 * Simple back navigation
39 */
40export function Breadcrumbs() {
41 return (
42 <div className="breadcrumbs text-sm">
105
106```javascript
107function hello() {
108 console.log("Hello, world!");
109}
5 * Main HTTP handler - entry point for all requests
6 */
7export default async function(req: Request): Promise<Response> {
8 return handleRequest(req);
9}
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;
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.