···11+# Fresh project
22+33+Your new Fresh project is ready to go. You can follow the Fresh "Getting
44+Started" guide here: https://fresh.deno.dev/docs/getting-started
55+66+### Usage
77+88+Make sure to install Deno: https://deno.land/manual/getting_started/installation
99+1010+Then start the project:
1111+1212+```
1313+deno task start
1414+```
1515+1616+This will watch the project directory and restart as necessary.
···11+#!/usr/bin/env -S deno run -A --watch=static/,routes/
22+33+import dev from "$fresh/dev.ts";
44+import config from "./fresh.config.ts";
55+66+import "$std/dotenv/load.ts";
77+88+await dev(import.meta.url, "./main.ts", config);
+6
fresh.config.ts
···11+import { defineConfig } from "$fresh/server.ts";
22+import tailwind from "$fresh/plugins/tailwind.ts";
33+44+export default defineConfig({
55+ plugins: [tailwind()],
66+});
+27
fresh.gen.ts
···11+// DO NOT EDIT. This file is generated by Fresh.
22+// This file SHOULD be checked into source version control.
33+// This file is automatically updated during development when running `dev.ts`.
44+55+import * as $_404 from "./routes/_404.tsx";
66+import * as $_app from "./routes/_app.tsx";
77+import * as $api_joke from "./routes/api/joke.ts";
88+import * as $greet_name_ from "./routes/greet/[name].tsx";
99+import * as $index from "./routes/index.tsx";
1010+import * as $Counter from "./islands/Counter.tsx";
1111+import type { Manifest } from "$fresh/server.ts";
1212+1313+const manifest = {
1414+ routes: {
1515+ "./routes/_404.tsx": $_404,
1616+ "./routes/_app.tsx": $_app,
1717+ "./routes/api/joke.ts": $api_joke,
1818+ "./routes/greet/[name].tsx": $greet_name_,
1919+ "./routes/index.tsx": $index,
2020+ },
2121+ islands: {
2222+ "./islands/Counter.tsx": $Counter,
2323+ },
2424+ baseUrl: import.meta.url,
2525+} satisfies Manifest;
2626+2727+export default manifest;
···11+import { FreshContext } from "$fresh/server.ts";
22+33+// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
44+const JOKES = [
55+ "Why do Java developers often wear glasses? They can't C#.",
66+ "A SQL query walks into a bar, goes up to two tables and says “can I join you?”",
77+ "Wasn't hard to crack Forrest Gump's password. 1forrest1.",
88+ "I love pressing the F5 key. It's refreshing.",
99+ "Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”",
1010+ "There are 10 types of people in the world. Those who understand binary and those who don't.",
1111+ "Why are assembly programmers often wet? They work below C level.",
1212+ "My favourite computer based band is the Black IPs.",
1313+ "What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.",
1414+ "An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
1515+];
1616+1717+export const handler = (_req: Request, _ctx: FreshContext): Response => {
1818+ const randomIndex = Math.floor(Math.random() * JOKES.length);
1919+ const body = JOKES[randomIndex];
2020+ return new Response(body);
2121+};
+5
routes/greet/[name].tsx
···11+import { PageProps } from "$fresh/server.ts";
22+33+export default function Greet(props: PageProps) {
44+ return <div>Hello {props.params.name}</div>;
55+}
+25
routes/index.tsx
···11+import { useSignal } from "@preact/signals";
22+import Counter from "../islands/Counter.tsx";
33+44+export default function Home() {
55+ const count = useSignal(3);
66+ return (
77+ <div class="px-4 py-8 mx-auto bg-[#86efac]">
88+ <div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
99+ <img
1010+ class="my-6"
1111+ src="/logo.svg"
1212+ width="128"
1313+ height="128"
1414+ alt="the Fresh logo: a sliced lemon dripping with juice"
1515+ />
1616+ <h1 class="text-4xl font-bold">Welcome to Fresh</h1>
1717+ <p class="my-4">
1818+ Try updating this message in the
1919+ <code class="mx-2">./routes/index.tsx</code> file, and refresh.
2020+ </p>
2121+ <Counter count={count} />
2222+ </div>
2323+ </div>
2424+ );
2525+}