Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

environment building #1

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Code quality

on:
push:
pull_request:

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci .
4 changes: 2 additions & 2 deletions app/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createClient } from 'honox/client'
import { createClient } from "honox/client";

createClient()
createClient();
17 changes: 8 additions & 9 deletions app/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {} from 'hono'
import {} from "hono";

type Head = {
title?: string
}
title?: string;
};

declare module 'hono' {
interface Env {
Variables: {}
Bindings: {}
}
declare module "hono" {
interface ContextRenderer {
(content: string | Promise<string>, head?: Head): Response | Promise<Response>
(
content: string | Promise<string>,
head?: Head,
): Response | Promise<Response>;
}
}
3 changes: 3 additions & 0 deletions app/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
10 changes: 6 additions & 4 deletions app/islands/counter.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useState } from 'hono/jsx'
import { useState } from "hono/jsx";

export default function Counter() {
const [count, setCount] = useState(0)
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
<button type="button" onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
)
);
}
10 changes: 5 additions & 5 deletions app/routes/_renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Style } from 'hono/css'
import { jsxRenderer } from 'hono/jsx-renderer'
import { Script } from 'honox/server'
import { Style } from "hono/css";
import { jsxRenderer } from "hono/jsx-renderer";
import { Script } from "honox/server";

export default jsxRenderer(({ children, title }) => {
return (
Expand All @@ -14,5 +14,5 @@ export default jsxRenderer(({ children, title }) => {
</head>
<body>{children}</body>
</html>
)
})
);
});
21 changes: 8 additions & 13 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { css } from 'hono/css'
import { createRoute } from 'honox/factory'
import Counter from '../islands/counter'

const className = css`
font-family: sans-serif;
`
import { createRoute } from "honox/factory";
import Counter from "../islands/counter";

export default createRoute((c) => {
const name = c.req.query('name') ?? 'Hono'
const name = c.req.query("name") ?? "Hono";
return c.render(
<div class={className}>
<h1>Hello, {name}!</h1>
<div>
<h1 className="text-3xl font-bold underline">Hello world! {name}</h1>
<Counter />
</div>,
{ title: name }
)
})
{ title: name },
);
});
10 changes: 5 additions & 5 deletions app/server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { showRoutes } from 'hono/dev'
import { createApp } from 'honox/server'
import { showRoutes } from "hono/dev";
import { createApp } from "honox/server";

const app = createApp()
const app = createApp();

showRoutes(app)
showRoutes(app);

export default app
export default app;
19 changes: 19 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"formatWithErrors": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"name": "basic",
"name": "blog",
"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"
"deploy": "$npm_execpath run build && wrangler pages deploy ./dist",
"format": "biome format --write .",
"lint": "biome lint .",
"check": "biome check --apply ."
},
"private": true,
"dependencies": {
"hono": "^4.0.5",
"honox": "^0.1.4"
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@cloudflare/workers-types": "^4.20240208.0",
"@hono/vite-cloudflare-pages": "^0.2.4",
"autoprefixer": "^10.4.17",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"vite": "^5.0.12",
"wrangler": "^3.27.0"
}
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
8 changes: 8 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./app/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
7 changes: 3 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ export default defineConfig(({ mode }) => {
return {
plugins: [client()],
};
} else {
return {
plugins: [honox(), pages()],
};
}
return {
plugins: [honox(), pages()],
};
});