Skip to content

Commit 2ab6232

Browse files
Merge pull request #563 from dao-xyz/feat/docs-site-v2
feat(site): peerbit.org docs site v2
2 parents 6fb8131 + e1e23d0 commit 2ab6232

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4452
-288
lines changed

.github/workflows/site.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Site
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- "apps/peerbit-org/**"
8+
- "docs/**"
9+
- "package.json"
10+
- "pnpm-lock.yaml"
11+
- "pnpm-workspace.yaml"
12+
- ".github/workflows/site.yml"
13+
pull_request:
14+
paths:
15+
- "apps/peerbit-org/**"
16+
- "docs/**"
17+
- "package.json"
18+
- "pnpm-lock.yaml"
19+
- "pnpm-workspace.yaml"
20+
- ".github/workflows/site.yml"
21+
22+
permissions:
23+
contents: read
24+
pages: write
25+
id-token: write
26+
27+
concurrency:
28+
group: "pages"
29+
cancel-in-progress: true
30+
31+
jobs:
32+
build:
33+
runs-on: ubuntu-22.04
34+
timeout-minutes: 20
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version: 22.x
41+
42+
- uses: pnpm/action-setup@v4
43+
with:
44+
run_install: false
45+
46+
- name: Install deps
47+
run: pnpm install --frozen-lockfile=false
48+
49+
- name: Build site
50+
env:
51+
SUPABASE_UPDATES_SYNC_URL: ${{ secrets.SUPABASE_UPDATES_SYNC_URL }}
52+
run: |
53+
if [ -n "$SUPABASE_UPDATES_SYNC_URL" ]; then
54+
export VITE_UPDATES_EMAIL_FORM_ACTION="${SUPABASE_UPDATES_SYNC_URL%/updates-sync}/updates-subscribe"
55+
fi
56+
pnpm --filter peerbit-org build
57+
58+
- name: Typecheck site
59+
run: pnpm --filter peerbit-org typecheck
60+
61+
- name: Sync Updates email
62+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && env.UPDATES_SYNC_URL != '' && env.UPDATES_SYNC_SECRET != ''
63+
env:
64+
UPDATES_SYNC_URL: ${{ secrets.SUPABASE_UPDATES_SYNC_URL }}
65+
UPDATES_SYNC_SECRET: ${{ secrets.SUPABASE_UPDATES_SYNC_SECRET }}
66+
run: |
67+
curl -sS -X POST "$UPDATES_SYNC_URL" \
68+
-H "Authorization: Bearer $UPDATES_SYNC_SECRET" \
69+
-H "Content-Type: application/json" \
70+
--data-binary @apps/peerbit-org/dist/content/docs/updates/index.json
71+
72+
- name: Upload Pages artifact
73+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
74+
uses: actions/upload-pages-artifact@v3
75+
with:
76+
path: apps/peerbit-org/dist
77+
78+
deploy:
79+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
80+
needs: build
81+
runs-on: ubuntu-22.04
82+
timeout-minutes: 20
83+
environment:
84+
name: github-pages
85+
url: ${{ steps.deployment.outputs.page_url }}
86+
steps:
87+
- id: deployment
88+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ coverage
2424
references
2525
.npmrc
2626
.env.github
27+
28+
# Supabase local secrets (do not commit)
29+
.env.supabase
30+
apps/peerbit-org/.env.supabase
31+
32+
# Vite local env (do not commit)
33+
apps/peerbit-org/.env.local
34+
apps/peerbit-org/.env.*.local
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copy to `apps/peerbit-org/.env.supabase` (this file is gitignored)
2+
#
3+
# This file is meant to contain everything needed to:
4+
# - deploy Supabase Edge Functions
5+
# - apply Supabase migrations
6+
# - set Supabase function secrets
7+
# - run the site locally with working Updates subscriptions
8+
#
9+
# ---- Supabase project (CLI / admin) ----
10+
SUPABASE_PROJECT_REF=your-project-ref
11+
SUPABASE_ACCESS_TOKEN=your-supabase-access-token
12+
SUPABASE_DB_PASSWORD=your-db-password
13+
14+
# Used by Edge Functions.
15+
# Note: `SUPABASE_*` names are reserved and already available in Edge Functions (the CLI will skip setting them as secrets).
16+
SUPABASE_URL=https://your-project-ref.supabase.co
17+
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
18+
19+
# ---- Email provider (Resend) ----
20+
RESEND_API_KEY=re_XXXXXXXXXXXXXXXXXXXXXXXXXXXX
21+
RESEND_FROM="Peerbit <updates@peerbit.org>"
22+
23+
# ---- Site / Updates settings ----
24+
SITE_URL=https://peerbit.org
25+
UPDATES_ALLOWED_ORIGINS=https://peerbit.org,http://localhost:5173
26+
UPDATES_SYNC_SECRET=replace-with-a-long-random-string
27+
28+
# Optional tuning
29+
UPDATES_CONFIRM_TTL_MINUTES=1440
30+
UPDATES_CONFIRM_THROTTLE_MINUTES=5
31+
32+
# ---- Site (Vite) ----
33+
# The subscribe dialog posts here. For local site dev, export this or copy it to `apps/peerbit-org/.env.local`.
34+
VITE_UPDATES_EMAIL_FORM_ACTION=https://your-project-ref.supabase.co/functions/v1/updates-subscribe

apps/peerbit-org/index.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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>Peerbit</title>
7+
<meta name="description" content="A P2P framework" />
8+
<meta property="og:title" content="Peerbit" />
9+
<meta property="og:description" content="A P2P framework" />
10+
<meta property="og:image" content="/content/docs/peerbit-logo.png" />
11+
<meta name="twitter:card" content="summary" />
12+
<link rel="alternate" type="application/rss+xml" title="Peerbit Updates" href="/content/docs/updates/all.xml" />
13+
<link rel="icon" href="/content/docs/media/favicon.ico" />
14+
<script>
15+
(() => {
16+
try {
17+
const key = "peerbit-theme";
18+
const stored = localStorage.getItem(key);
19+
const prefersDark =
20+
window.matchMedia &&
21+
window.matchMedia("(prefers-color-scheme: dark)").matches;
22+
const theme =
23+
stored === "dark" || stored === "light"
24+
? stored
25+
: prefersDark
26+
? "dark"
27+
: "light";
28+
document.documentElement.classList.toggle("dark", theme === "dark");
29+
} catch {
30+
// ignore
31+
}
32+
})();
33+
</script>
34+
</head>
35+
<body>
36+
<div id="root"></div>
37+
<script type="module" src="/src/main.tsx"></script>
38+
</body>
39+
</html>

apps/peerbit-org/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "peerbit-org",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview",
10+
"typecheck": "tsc -p tsconfig.json --noEmit"
11+
},
12+
"dependencies": {
13+
"highlight.js": "^11.11.1",
14+
"iconoir-react": "^7.11.0",
15+
"react": "^18.3.1",
16+
"react-dom": "^18.3.1",
17+
"react-markdown": "^9.0.3",
18+
"react-router-dom": "^6.28.0",
19+
"rehype-raw": "^7.0.0",
20+
"remark-gfm": "^4.0.1"
21+
},
22+
"devDependencies": {
23+
"@tailwindcss/typography": "^0.5.16",
24+
"@tailwindcss/vite": "^4.0.0",
25+
"@types/react": "^18.3.11",
26+
"@types/react-dom": "^18.3.0",
27+
"@vitejs/plugin-react": "^4.3.4",
28+
"tailwindcss": "^4.0.0",
29+
"typescript": "^5.6.3",
30+
"vite": "^7.0.0"
31+
}
32+
}

apps/peerbit-org/public/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

apps/peerbit-org/public/CNAME

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
peerbit.org
2+

apps/peerbit-org/src/App.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { HashRouter, Navigate, Route, Routes } from "react-router-dom";
2+
3+
import { AppLayout } from "./layout/AppLayout";
4+
import { HomePage } from "./pages/HomePage";
5+
import { MarkdownDocPage } from "./pages/MarkdownDocPage";
6+
import { StatusPage } from "./pages/StatusPage";
7+
import { UpdatesPage } from "./pages/UpdatesPage";
8+
9+
export default function App() {
10+
return (
11+
<HashRouter>
12+
<Routes>
13+
<Route element={<AppLayout />}>
14+
<Route index element={<HomePage />} />
15+
<Route path="status" element={<StatusPage />} />
16+
17+
<Route path="docs" element={<Navigate to="/docs/getting-started" replace />} />
18+
<Route path="docs/*" element={<MarkdownDocPage base="content/docs" />} />
19+
20+
<Route path="updates" element={<UpdatesPage />} />
21+
<Route path="blog" element={<Navigate to="/updates" replace />} />
22+
<Route
23+
path="release-notes"
24+
element={<MarkdownDocPage base="content/docs" doc="release-notes.md" />}
25+
/>
26+
27+
<Route path="*" element={<MarkdownDocPage base="content/docs" />} />
28+
</Route>
29+
</Routes>
30+
</HashRouter>
31+
);
32+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Outlet } from "react-router-dom";
2+
3+
import { Header } from "./Header";
4+
5+
export function AppLayout() {
6+
return (
7+
<div className="min-h-screen">
8+
<Header />
9+
<div className="mx-auto w-full max-w-6xl px-4 py-8">
10+
<Outlet />
11+
</div>
12+
</div>
13+
);
14+
}
15+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ReactNode } from "react";
2+
3+
import { DocsSidebar } from "./DocsSidebar";
4+
5+
export function DocsLayout({ children }: { children: ReactNode }) {
6+
return (
7+
<div className="grid grid-cols-1 gap-8 lg:grid-cols-[280px_minmax(0,1fr)]">
8+
<aside className="hidden lg:block">
9+
<div className="sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto pr-2">
10+
<DocsSidebar />
11+
</div>
12+
</aside>
13+
<main>{children}</main>
14+
</div>
15+
);
16+
}
17+

0 commit comments

Comments
 (0)