diff --git a/.gitignore b/.gitignore index 1a1b0be..875e848 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,18 @@ -# nix build results -/result +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# Fresh build directory +_fresh/ + +# npm dependencies +node_modules/ # direnv cache /.direnv + +# nix build results +/result diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec0e33e --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Fresh project + +Your new Fresh project is ready to go. You can follow the Fresh "Getting +Started" guide here: https://fresh.deno.dev/docs/getting-started + +### Usage + +Make sure to install Deno: https://deno.land/manual/getting_started/installation + +Then start the project: + +``` +deno task start +``` + +This will watch the project directory and restart as necessary. diff --git a/components/Button.tsx b/components/Button.tsx new file mode 100644 index 0000000..a07f8a8 --- /dev/null +++ b/components/Button.tsx @@ -0,0 +1,12 @@ +import { JSX } from 'preact' +import { IS_BROWSER } from '$fresh/runtime.ts' + +export function Button(props: JSX.HTMLAttributes) { + return ( + +

{props.count}

+ + + ) +} diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..13d2f71 --- /dev/null +++ b/main.ts @@ -0,0 +1,13 @@ +/// +/// +/// +/// +/// + +import '$std/dotenv/load.ts' + +import { start } from '$fresh/server.ts' +import manifest from './fresh.gen.ts' +import config from './fresh.config.ts' + +await start(manifest, config) diff --git a/routes/_404.tsx b/routes/_404.tsx new file mode 100644 index 0000000..61a430c --- /dev/null +++ b/routes/_404.tsx @@ -0,0 +1,27 @@ +import { Head } from '$fresh/runtime.ts' + +export default function Error404() { + return ( + <> + + 404 - Page not found + +
+
+ the Fresh logo: a sliced lemon dripping with juice +

404 - Page not found

+

+ The page you were looking for doesn't exist. +

+ Go back home +
+
+ + ) +} diff --git a/routes/_app.tsx b/routes/_app.tsx new file mode 100644 index 0000000..8a32ed5 --- /dev/null +++ b/routes/_app.tsx @@ -0,0 +1,16 @@ +import { type PageProps } from '$fresh/server.ts' +export default function App({ Component }: PageProps) { + return ( + + + + + bank + + + + + + + ) +} diff --git a/routes/api/joke.ts b/routes/api/joke.ts new file mode 100644 index 0000000..90f1585 --- /dev/null +++ b/routes/api/joke.ts @@ -0,0 +1,21 @@ +import { FreshContext } from '$fresh/server.ts' + +// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/ +const JOKES = [ + "Why do Java developers often wear glasses? They can't C#.", + 'A SQL query walks into a bar, goes up to two tables and says “can I join you?”', + "Wasn't hard to crack Forrest Gump's password. 1forrest1.", + "I love pressing the F5 key. It's refreshing.", + 'Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”', + "There are 10 types of people in the world. Those who understand binary and those who don't.", + 'Why are assembly programmers often wet? They work below C level.', + 'My favourite computer based band is the Black IPs.', + 'What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.', + 'An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.', +] + +export const handler = (_req: Request, _ctx: FreshContext): Response => { + const randomIndex = Math.floor(Math.random() * JOKES.length) + const body = JOKES[randomIndex] + return new Response(body) +} diff --git a/routes/greet/[name].tsx b/routes/greet/[name].tsx new file mode 100644 index 0000000..35067e8 --- /dev/null +++ b/routes/greet/[name].tsx @@ -0,0 +1,5 @@ +import { PageProps } from '$fresh/server.ts' + +export default function Greet(props: PageProps) { + return
Hello {props.params.name}
+} diff --git a/routes/index.tsx b/routes/index.tsx new file mode 100644 index 0000000..83f82eb --- /dev/null +++ b/routes/index.tsx @@ -0,0 +1,25 @@ +import { useSignal } from '@preact/signals' +import Counter from '../islands/Counter.tsx' + +export default function Home() { + const count = useSignal(3) + return ( +
+
+ the Fresh logo: a sliced lemon dripping with juice +

Welcome to Fresh

+

+ Try updating this message in the + ./routes/index.tsx file, and refresh. +

+ +
+
+ ) +} diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..1cfaaa2 Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/logo.svg b/static/logo.svg new file mode 100644 index 0000000..ef2fbe4 --- /dev/null +++ b/static/logo.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/static/styles.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/tailwind.config.ts b/tailwind.config.ts new file mode 100644 index 0000000..b83c50d --- /dev/null +++ b/tailwind.config.ts @@ -0,0 +1,7 @@ +import { type Config } from 'tailwindcss' + +export default { + content: [ + '{routes,islands,components}/**/*.{ts,tsx}', + ], +} satisfies Config