From 5784894f96093ffdb9c7a439daad1e9b3c716f9a Mon Sep 17 00:00:00 2001 From: yossydev Date: Thu, 22 Feb 2024 17:17:34 +0900 Subject: [PATCH] first commit --- .gitignore | 12 ++++++++++++ app/client.ts | 3 +++ app/global.d.ts | 15 +++++++++++++++ app/islands/counter.tsx | 11 +++++++++++ app/routes/_renderer.tsx | 18 ++++++++++++++++++ app/routes/index.tsx | 18 ++++++++++++++++++ app/server.ts | 8 ++++++++ package.json | 21 +++++++++++++++++++++ tsconfig.json | 17 +++++++++++++++++ vite.config.ts | 16 ++++++++++++++++ 10 files changed, 139 insertions(+) create mode 100644 .gitignore create mode 100644 app/client.ts create mode 100644 app/global.d.ts create mode 100644 app/islands/counter.tsx create mode 100644 app/routes/_renderer.tsx create mode 100644 app/routes/index.tsx create mode 100644 app/server.ts create mode 100644 package.json create mode 100644 tsconfig.json create mode 100644 vite.config.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcab6ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +node_modules +dist +.wrangler +.dev.vars +.hono + +# Change them to your taste: +wrangler.toml +package-lock.json +yarn.lock +pnpm-lock.yaml +bun.lockb \ No newline at end of file diff --git a/app/client.ts b/app/client.ts new file mode 100644 index 0000000..16ecf96 --- /dev/null +++ b/app/client.ts @@ -0,0 +1,3 @@ +import { createClient } from 'honox/client' + +createClient() diff --git a/app/global.d.ts b/app/global.d.ts new file mode 100644 index 0000000..288f02b --- /dev/null +++ b/app/global.d.ts @@ -0,0 +1,15 @@ +import {} from 'hono' + +type Head = { + title?: string +} + +declare module 'hono' { + interface Env { + Variables: {} + Bindings: {} + } + interface ContextRenderer { + (content: string | Promise, head?: Head): Response | Promise + } +} diff --git a/app/islands/counter.tsx b/app/islands/counter.tsx new file mode 100644 index 0000000..0bb5438 --- /dev/null +++ b/app/islands/counter.tsx @@ -0,0 +1,11 @@ +import { useState } from 'hono/jsx' + +export default function Counter() { + const [count, setCount] = useState(0) + return ( +
+

{count}

+ +
+ ) +} diff --git a/app/routes/_renderer.tsx b/app/routes/_renderer.tsx new file mode 100644 index 0000000..f72c28f --- /dev/null +++ b/app/routes/_renderer.tsx @@ -0,0 +1,18 @@ +import { Style } from 'hono/css' +import { jsxRenderer } from 'hono/jsx-renderer' +import { Script } from 'honox/server' + +export default jsxRenderer(({ children, title }) => { + return ( + + + + + {title} +