-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yossydev
committed
Feb 22, 2024
0 parents
commit 5784894
Showing
10 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { createClient } from 'honox/client' | ||
|
||
createClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {} from 'hono' | ||
|
||
type Head = { | ||
title?: string | ||
} | ||
|
||
declare module 'hono' { | ||
interface Env { | ||
Variables: {} | ||
Bindings: {} | ||
} | ||
interface ContextRenderer { | ||
(content: string | Promise<string>, head?: Head): Response | Promise<Response> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useState } from 'hono/jsx' | ||
|
||
export default function Counter() { | ||
const [count, setCount] = useState(0) | ||
return ( | ||
<div> | ||
<p>{count}</p> | ||
<button onClick={() => setCount(count + 1)}>Increment</button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>{title}</title> | ||
<Script src="/app/client.ts" async /> | ||
<Style /> | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { css } from 'hono/css' | ||
import { createRoute } from 'honox/factory' | ||
import Counter from '../islands/counter' | ||
|
||
const className = css` | ||
font-family: sans-serif; | ||
` | ||
|
||
export default createRoute((c) => { | ||
const name = c.req.query('name') ?? 'Hono' | ||
return c.render( | ||
<div class={className}> | ||
<h1>Hello, {name}!</h1> | ||
<Counter /> | ||
</div>, | ||
{ title: name } | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { showRoutes } from 'hono/dev' | ||
import { createApp } from 'honox/server' | ||
|
||
const app = createApp() | ||
|
||
showRoutes(app) | ||
|
||
export default app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "basic", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build --mode client && vite build", | ||
"preview": "wrangler pages dev ./dist", | ||
"deploy": "$npm_execpath run build && wrangler pages deploy ./dist" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"hono": "^4.0.5", | ||
"honox": "^0.1.4" | ||
}, | ||
"devDependencies": { | ||
"@cloudflare/workers-types": "^4.20240208.0", | ||
"@hono/vite-cloudflare-pages": "^0.2.4", | ||
"vite": "^5.0.12", | ||
"wrangler": "^3.27.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"strict": true, | ||
"lib": [ | ||
"ESNext", | ||
"DOM" | ||
], | ||
"types": [ | ||
"@cloudflare/workers-types" | ||
], | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "hono/jsx" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pages from "@hono/vite-cloudflare-pages"; | ||
import honox from "honox/vite"; | ||
import client from "honox/vite/client"; | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig(({ mode }) => { | ||
if (mode === "client") { | ||
return { | ||
plugins: [client()], | ||
}; | ||
} else { | ||
return { | ||
plugins: [honox(), pages()], | ||
}; | ||
} | ||
}); |