commit 0397843a92390d05970778ee8ab655fae274ea1c Author: Daniel Flanagan Date: Fri Jan 5 13:22:56 2024 -0600 Initial commit diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba59dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/.direnv + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# Fresh build directory +_fresh/ +# npm dependencies +node_modules/ diff --git a/.helix/languages.toml b/.helix/languages.toml new file mode 100644 index 0000000..b05ee97 --- /dev/null +++ b/.helix/languages.toml @@ -0,0 +1,49 @@ +[language-server.deno] +command = "deno" +args = ["lsp"] +config.hostInfo = "helix" + +[[language]] +name = "javascript" +scope = "source.js" +injection-regex = "(js|javascript)" +language-id = "javascript" +file-types = ["js", "mjs", "cjs", "rules", "es6", "pac", "jakefile"] +shebangs = ["node"] +comment-token = "//" +language-servers = [ "deno" ] +indent = { tab-width = 2, unit = "\t" } +auto-format = true + +[[language]] +name = "jsx" +scope = "source.jsx" +injection-regex = "jsx" +language-id = "javascriptreact" +file-types = ["jsx"] +comment-token = "//" +language-servers = [ "deno" ] +indent = { tab-width = 2, unit = "\t" } +grammar = "javascript" +auto-format = true + +[[language]] +name = "typescript" +scope = "source.ts" +injection-regex = "(ts|typescript)" +file-types = ["ts", "mts", "cts"] +language-id = "typescript" +shebangs = ["deno", "ts-node"] +language-servers = [ "deno" ] +indent = { tab-width = 2, unit = "\t" } +auto-format = true + +[[language]] +name = "tsx" +scope = "source.tsx" +injection-regex = "(tsx)" +language-id = "typescriptreact" +file-types = ["tsx"] +language-servers = [ "deno" ] +indent = { tab-width = 2, unit = "\t" } +auto-format = true 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/models.ts b/models.ts new file mode 100644 index 0000000..4329fdd --- /dev/null +++ b/models.ts @@ -0,0 +1,13 @@ +type Name = string + +export interface FamilyMember { + name: Name + avatarUrl?: URL +} + +export interface ToDo { + emoji?: string + description: string + doneAt?: Date + assigneeName?: Name +} 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..d716935 --- /dev/null +++ b/routes/_app.tsx @@ -0,0 +1,17 @@ +import { type PageProps } from '$fresh/server.ts' +export default function App({ Component }: PageProps) { + return ( + + + + + homeman-deno + + + + meow + + + + ) +} diff --git a/routes/api/joke.ts b/routes/api/joke.ts new file mode 100644 index 0000000..be9d585 --- /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..583a9a0 --- /dev/null +++ b/routes/index.tsx @@ -0,0 +1,40 @@ +import { Handlers } from '$fresh/server.ts' +import { useSignal } from '@preact/signals' +import Counter from '../islands/Counter.tsx' +import { FamilyMember, ToDo } from '$models' + +interface Data { + familyMembers: FamilyMember[] + todos: ToDo[] +} + +export const handler: Handlers = { + async GET(_req, ctx) { + const resp = await ctx.render() + resp.headers.set('X-Custom-Header', 'Hello') + return resp + }, +} + +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