Skip to content

Commit a34a026

Browse files
committed
Initialize Eleventy project with configuration, layouts, and content structure; add package management with Bun and GitHub Actions for deployment.
1 parent 0403e54 commit a34a026

File tree

20 files changed

+1082
-97
lines changed

20 files changed

+1082
-97
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
3+
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4+
alwaysApply: false
5+
---
6+
7+
Default to using Bun instead of Node.js.
8+
9+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10+
- Use `bun test` instead of `jest` or `vitest`
11+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14+
- Bun automatically loads .env, so don't use dotenv.
15+
16+
## APIs
17+
18+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20+
- `Bun.redis` for Redis. Don't use `ioredis`.
21+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22+
- `WebSocket` is built-in. Don't use `ws`.
23+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24+
- Bun.$`ls` instead of execa.
25+
26+
## Testing
27+
28+
Use `bun test` to run tests.
29+
30+
```ts#index.test.ts
31+
import { test, expect } from "bun:test";
32+
33+
test("hello world", () => {
34+
expect(1).toBe(1);
35+
});
36+
```
37+
38+
## Frontend
39+
40+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41+
42+
Server:
43+
44+
```ts#index.ts
45+
import index from "./index.html"
46+
47+
Bun.serve({
48+
routes: {
49+
"/": index,
50+
"/api/users/:id": {
51+
GET: (req) => {
52+
return new Response(JSON.stringify({ id: req.params.id }));
53+
},
54+
},
55+
},
56+
// optional websocket support
57+
websocket: {
58+
open: (ws) => {
59+
ws.send("Hello, world!");
60+
},
61+
message: (ws, message) => {
62+
ws.send(message);
63+
},
64+
close: (ws) => {
65+
// handle close
66+
}
67+
},
68+
development: {
69+
hmr: true,
70+
console: true,
71+
}
72+
})
73+
```
74+
75+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
76+
77+
```html#index.html
78+
<html>
79+
<body>
80+
<h1>Hello, world!</h1>
81+
<script type="module" src="./frontend.tsx"></script>
82+
</body>
83+
</html>
84+
```
85+
86+
With the following `frontend.tsx`:
87+
88+
```tsx#frontend.tsx
89+
import React from "react";
90+
91+
// import .css files directly and it works
92+
import './index.css';
93+
94+
import { createRoot } from "react-dom/client";
95+
96+
const root = createRoot(document.body);
97+
98+
export default function Frontend() {
99+
return <h1>Hello, world!</h1>;
100+
}
101+
102+
root.render(<Frontend />);
103+
```
104+
105+
Then, run index.ts
106+
107+
```sh
108+
bun --hot ./index.ts
109+
```
110+
111+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.

.eleventy.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @ts-check
2+
/**
3+
* @param {import("@11ty/eleventy").EleventyConfig} eleventyConfig
4+
* @returns {import("@11ty/eleventy").EleventyReturnValue}
5+
*/
6+
module.exports = (eleventyConfig) => {
7+
eleventyConfig.addPassthroughCopy("styles.css");
8+
eleventyConfig.addPassthroughCopy("*.png");
9+
eleventyConfig.addPassthroughCopy(".well-known");
10+
eleventyConfig.addPassthroughCopy("CNAME");
11+
12+
eleventyConfig.setServerOptions({
13+
port: 3000
14+
});
15+
16+
return {
17+
dir: {
18+
input: "content",
19+
output: "_site",
20+
includes: "../_includes",
21+
layouts: "../_layouts"
22+
},
23+
markdownTemplateEngine: "njk",
24+
htmlTemplateEngine: "njk",
25+
templateFormats: ["html", "md", "njk"]
26+
};
27+
};

.github/workflows/deploy.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: jdx/mise-action@v2
24+
with:
25+
experimental: true
26+
27+
- run: mise run build
28+
29+
- uses: actions/upload-pages-artifact@v3
30+
with:
31+
path: _site
32+
33+
deploy:
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- uses: actions/deploy-pages@v4
41+
id: deployment

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
_site/
3+
.DS_Store
4+
.vscode/settings.json

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# rust-nyc.github.io
2+
3+
To install dependencies:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
To run:
10+
11+
```bash
12+
bun run
13+
```
14+
15+
This project was created using `bun init` in bun v1.3.1. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.

_layouts/base.njk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>{{ title or "Rust NYC" }}</title>
7+
<link href="/styles.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
{{ content | safe }}
11+
</body>
12+
</html>

_layouts/redirect.njk

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="refresh" content="0; url={{ redirect }}">
6+
<link rel="canonical" href="{{ redirect }}">
7+
<title>Redirecting...</title>
8+
<style>
9+
html {
10+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
11+
font-size: 16px;
12+
line-height: 1.6;
13+
color: #222;
14+
background-color: #fff;
15+
}
16+
body {
17+
display: flex;
18+
flex-direction: column;
19+
align-items: center;
20+
justify-content: center;
21+
min-height: 100vh;
22+
margin: 0;
23+
padding: 2rem;
24+
text-align: center;
25+
}
26+
.ferris {
27+
width: 120px;
28+
height: auto;
29+
margin-bottom: 1.5rem;
30+
}
31+
.message {
32+
font-size: 1.25rem;
33+
margin-bottom: 1rem;
34+
}
35+
a {
36+
color: #2D8CFF;
37+
text-decoration: none;
38+
font-weight: 500;
39+
}
40+
a:hover {
41+
text-decoration: underline;
42+
}
43+
</style>
44+
</head>
45+
<body>
46+
<img src="/rust-nyc-liberty-ferris.png" alt="Ferris" class="ferris">
47+
<p class="message">Redirecting you...</p>
48+
<p>Taking you to <a href="{{ redirect }}">{{ redirect }}</a></p>
49+
</body>
50+
</html>

_layouts/zoom.njk

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>{{ title or "Rust NYC Zoom" }}</title>
7+
<link href="/styles.css" rel="stylesheet">
8+
<style>
9+
.zoom-container {
10+
max-width: 600px;
11+
margin: 2rem auto;
12+
padding: 2rem;
13+
text-align: center;
14+
}
15+
.meeting-id {
16+
font-size: 3rem;
17+
font-weight: bold;
18+
font-family: monospace;
19+
letter-spacing: 0.1em;
20+
margin: 1.5rem 0;
21+
color: #2D8CFF;
22+
user-select: all;
23+
}
24+
.join-button {
25+
display: inline-block;
26+
background: #2D8CFF;
27+
color: white;
28+
padding: 1rem 2rem;
29+
font-size: 1.25rem;
30+
font-weight: bold;
31+
text-decoration: none;
32+
border-radius: 8px;
33+
margin: 1.5rem 0;
34+
transition: background 0.2s;
35+
}
36+
.join-button:hover {
37+
background: #1a75e8;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<div class="zoom-container">
43+
{{ content | safe }}
44+
</div>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)