├── static
├── favicon.ico
└── logo.svg
├── .vscode
├── extensions.json
└── settings.json
├── routes
├── greet
│ └── [name].tsx
├── _app.tsx
├── index.tsx
├── _404.tsx
└── api
│ └── joke.ts
├── .gitignore
├── dev.ts
├── fresh.config.ts
├── twind.config.ts
├── components
└── Button.tsx
├── main.ts
├── README.md
├── islands
└── Counter.tsx
├── fresh.gen.ts
└── deno.json
/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denoland/fresh_template/HEAD/static/favicon.ico
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "denoland.vscode-deno"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/routes/greet/[name].tsx:
--------------------------------------------------------------------------------
1 | import { PageProps } from "$fresh/server.ts";
2 |
3 | export default function Greet(props: PageProps) {
4 | return
Hello {props.params.name}
;
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # dotenv environment variable files
2 | .env
3 | .env.development.local
4 | .env.test.local
5 | .env.production.local
6 | .env.local
7 |
8 | # Fresh build directory
9 | _fresh/
10 | # npm dependencies
11 | node_modules/
12 |
--------------------------------------------------------------------------------
/dev.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env -S deno run -A --watch=static/,routes/
2 |
3 | import dev from "$fresh/dev.ts";
4 | import config from "./fresh.config.ts";
5 |
6 | import "$std/dotenv/load.ts";
7 |
8 | await dev(import.meta.url, "./main.ts", config);
9 |
--------------------------------------------------------------------------------
/fresh.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "$fresh/server.ts";
2 | import twind from "$fresh/plugins/twindv1.ts";
3 | import twindConfig from "./twind.config.ts";
4 |
5 | export default defineConfig({
6 | plugins: [twind(twindConfig)],
7 | });
8 |
--------------------------------------------------------------------------------
/twind.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig, Preset } from "@twind/core";
2 | import presetTailwind from "@twind/preset-tailwind";
3 | import presetAutoprefix from "@twind/preset-autoprefix";
4 |
5 | export default {
6 | ...defineConfig({
7 | presets: [presetTailwind() as Preset, presetAutoprefix() as Preset],
8 | }),
9 | selfURL: import.meta.url,
10 | };
11 |
--------------------------------------------------------------------------------
/components/Button.tsx:
--------------------------------------------------------------------------------
1 | import { JSX } from "preact";
2 | import { IS_BROWSER } from "$fresh/runtime.ts";
3 |
4 | export function Button(props: JSX.HTMLAttributes) {
5 | return (
6 |
11 | );
12 | }
13 |
--------------------------------------------------------------------------------
/main.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 |
7 | import "$std/dotenv/load.ts";
8 |
9 | import { start } from "$fresh/server.ts";
10 | import manifest from "./fresh.gen.ts";
11 | import config from "./fresh.config.ts";
12 |
13 | await start(manifest, config);
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fresh project
2 |
3 | Your new Fresh project is ready to go. You can follow the Fresh "Getting
4 | Started" guide here: https://fresh.deno.dev/docs/getting-started
5 |
6 | ### Usage
7 |
8 | Make sure to install Deno: https://deno.land/manual/getting_started/installation
9 |
10 | Then start the project:
11 |
12 | ```
13 | deno task start
14 | ```
15 |
16 | This will watch the project directory and restart as necessary.
17 |
--------------------------------------------------------------------------------
/routes/_app.tsx:
--------------------------------------------------------------------------------
1 | import { type PageProps } from "$fresh/server.ts";
2 | export default function App({ Component }: PageProps) {
3 | return (
4 |
5 |
6 |
7 |
8 | fresh_template
9 |
10 |
11 |
12 |
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "deno.enable": true,
3 | "deno.lint": true,
4 | "editor.defaultFormatter": "denoland.vscode-deno",
5 | "[typescriptreact]": {
6 | "editor.defaultFormatter": "denoland.vscode-deno"
7 | },
8 | "[typescript]": {
9 | "editor.defaultFormatter": "denoland.vscode-deno"
10 | },
11 | "[javascriptreact]": {
12 | "editor.defaultFormatter": "denoland.vscode-deno"
13 | },
14 | "[javascript]": {
15 | "editor.defaultFormatter": "denoland.vscode-deno"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/islands/Counter.tsx:
--------------------------------------------------------------------------------
1 | import type { Signal } from "@preact/signals";
2 | import { Button } from "../components/Button.tsx";
3 |
4 | interface CounterProps {
5 | count: Signal;
6 | }
7 |
8 | export default function Counter(props: CounterProps) {
9 | return (
10 |
11 |
12 |
{props.count}
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/routes/index.tsx:
--------------------------------------------------------------------------------
1 | import { useSignal } from "@preact/signals";
2 | import Counter from "../islands/Counter.tsx";
3 |
4 | export default function Home() {
5 | const count = useSignal(3);
6 | return (
7 |
8 |
9 |

16 |
Welcome to Fresh
17 |
18 | Try updating this message in the
19 | ./routes/index.tsx file, and refresh.
20 |
21 |
22 |
23 |
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/routes/_404.tsx:
--------------------------------------------------------------------------------
1 | import { Head } from "$fresh/runtime.ts";
2 |
3 | export default function Error404() {
4 | return (
5 | <>
6 |
7 | 404 - Page not found
8 |
9 |
10 |
11 |

18 |
404 - Page not found
19 |
20 | The page you were looking for doesn't exist.
21 |
22 |
Go back home
23 |
24 |
25 | >
26 | );
27 | }
28 |
--------------------------------------------------------------------------------
/fresh.gen.ts:
--------------------------------------------------------------------------------
1 | // DO NOT EDIT. This file is generated by Fresh.
2 | // This file SHOULD be checked into source version control.
3 | // This file is automatically updated during development when running `dev.ts`.
4 |
5 | import * as $_404 from "./routes/_404.tsx";
6 | import * as $_app from "./routes/_app.tsx";
7 | import * as $api_joke from "./routes/api/joke.ts";
8 | import * as $greet_name_ from "./routes/greet/[name].tsx";
9 | import * as $index from "./routes/index.tsx";
10 | import * as $Counter from "./islands/Counter.tsx";
11 | import type { Manifest } from "$fresh/server.ts";
12 |
13 | const manifest = {
14 | routes: {
15 | "./routes/_404.tsx": $_404,
16 | "./routes/_app.tsx": $_app,
17 | "./routes/api/joke.ts": $api_joke,
18 | "./routes/greet/[name].tsx": $greet_name_,
19 | "./routes/index.tsx": $index,
20 | },
21 | islands: {
22 | "./islands/Counter.tsx": $Counter,
23 | },
24 | baseUrl: import.meta.url,
25 | } satisfies Manifest;
26 |
27 | export default manifest;
28 |
--------------------------------------------------------------------------------
/static/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/routes/api/joke.ts:
--------------------------------------------------------------------------------
1 | import { FreshContext } from "$fresh/server.ts";
2 |
3 | // Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
4 | const JOKES = [
5 | "Why do Java developers often wear glasses? They can't C#.",
6 | "A SQL query walks into a bar, goes up to two tables and says “can I join you?”",
7 | "Wasn't hard to crack Forrest Gump's password. 1forrest1.",
8 | "I love pressing the F5 key. It's refreshing.",
9 | "Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”",
10 | "There are 10 types of people in the world. Those who understand binary and those who don't.",
11 | "Why are assembly programmers often wet? They work below C level.",
12 | "My favourite computer based band is the Black IPs.",
13 | "What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.",
14 | "An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
15 | ];
16 |
17 | export const handler = (_req: Request, _ctx: FreshContext): Response => {
18 | const randomIndex = Math.floor(Math.random() * JOKES.length);
19 | const body = JOKES[randomIndex];
20 | return new Response(body);
21 | };
22 |
--------------------------------------------------------------------------------
/deno.json:
--------------------------------------------------------------------------------
1 | {
2 | "lock": false,
3 | "tasks": {
4 | "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
5 | "cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
6 | "manifest": "deno task cli manifest $(pwd)",
7 | "start": "deno run -A --watch=static/,routes/ dev.ts",
8 | "build": "deno run -A dev.ts build",
9 | "preview": "deno run -A main.ts",
10 | "update": "deno run -A -r https://fresh.deno.dev/update ."
11 | },
12 | "lint": {
13 | "rules": {
14 | "tags": [
15 | "fresh",
16 | "recommended"
17 | ]
18 | }
19 | },
20 | "exclude": [
21 | "**/_fresh/*"
22 | ],
23 | "imports": {
24 | "$fresh/": "https://deno.land/x/fresh@1.7.3/",
25 | "preact": "https://esm.sh/preact@10.22.0",
26 | "preact/": "https://esm.sh/preact@10.22.0/",
27 | "@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
28 | "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
29 | "@twind/core": "https://esm.sh/@twind/core@1.1.3",
30 | "@twind/preset-tailwind": "https://esm.sh/@twind/preset-tailwind@1.1.4/",
31 | "@twind/preset-autoprefix": "https://esm.sh/@twind/preset-autoprefix@1.0.7/",
32 | "$std/": "https://deno.land/std@0.216.0/"
33 | },
34 | "compilerOptions": {
35 | "jsx": "react-jsx",
36 | "jsxImportSource": "preact"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------