Branchwell

Skillfarm / website · skillfarm.ai / src / views / layout.tsx

Raw 7.2 KB on c724bfa127f7a93b48788385cedf1e60cb4e7943
1import { html } from 'hono/html';
2import type { Child, FC } from 'hono/jsx';
3import type { Ctx, User } from '../env';
4import { VERSION } from '../env';
5import { brandMark, icon, spot } from './art';
6import { Avatar } from './components';
7
8type PageProps = {
9 title?: string;
10 description?: string;
11 image?: string;
12 noindex?: boolean;
13 active?: string;
14 narrow?: boolean;
15 bare?: boolean;
16 children?: Child;
17};
18
19const DEFAULT_DESC = 'Skillfarm is a curated list of agent skills for Claude Code, Codex CLI and Gemini CLI. Every shared skill is reviewed by a person before it goes live. Free to browse and share, and you earn Seeds as you grow.';
20
21const NAV = [
22 { href: '/skills', label: 'Skills', key: 'skills' },
23 { href: '/prompts', label: 'Prompts', key: 'prompts' },
24 { href: '/growers', label: 'Growers', key: 'growers' },
25 { href: '/leaderboard', label: 'Leaderboard', key: 'leaderboard' },
26 { href: '/seeds', label: 'Seeds', key: 'seeds' },
27 { href: '/connect', label: 'MCP', key: 'connect' },
28 { href: '/help', label: 'Help', key: 'help' },
29];
30
31
32const Header: FC<{ user: User | null; active?: string; path: string }> = ({ user, active, path }) => (
33 <header class="site-header">
34 <div class="wrap header-row">
35 <a href="/" class="brand" aria-label="Skillfarm home">
36 {brandMark(32)}
37 <span>Skillfarm</span>
38 </a>
39 <nav class="main-nav" id="main-nav" aria-label="Main">
40 {NAV.map((n) => (
41 <a href={n.href} class={active === n.key ? 'is-active' : ''} aria-current={active === n.key ? 'page' : undefined}>
42 {n.label}
43 </a>
44 ))}
45 </nav>
46 <div class="header-actions">
47 <a href="/share" class="btn btn-sun btn-sm">Share a skill</a>
48 {user ? (
49 <details class="menu">
50 <summary aria-label="Your account">
51 <Avatar user={user} size={34} />
52 </summary>
53 <div class="menu-panel">
54 <div class="menu-who">
55 <strong>{user.display_name}</strong>
56 <span>@{user.handle}</span>
57 </div>
58 <a href={`/u/${user.handle}`}>Your profile</a>
59 <a href="/settings">Settings</a>
60 {user.is_admin ? <a href="/admin">Review queue</a> : null}
61 <form method="post" action="/signout">
62 <button type="submit">Sign out</button>
63 </form>
64 </div>
65 </details>
66 ) : (
67 <a href={`/signin?next=${encodeURIComponent(path)}`} class="btn btn-ghost btn-sm">Sign in</a>
68 )}
69 <button class="nav-toggle" type="button" aria-controls="main-nav" aria-expanded="false" aria-label="Menu" data-nav-toggle>
70 {icon('menu', 22)}
71 </button>
72 </div>
73 </div>
74 </header>
75);
76
77const Footer: FC<{ path: string }> = ({ path }) => (
78 <footer class="site-footer">
79 <div class="wrap footer-grid">
80 <div class="footer-about">
81 <a href="/" class="brand brand-light">
82 {brandMark(30)}
83 <span>Skillfarm</span>
84 </a>
85 <p>A curated list of agent skills, free for everyone. Every shared skill is reviewed before it goes live.</p>
86 </div>
87 <nav aria-label="Explore">
88 <h2>Explore</h2>
89 <a href="/skills">Browse skills</a>
90 <a href="/skills?sort=trending">Trending</a>
91 <a href="/prompts">Prompts</a>
92 <a href="/growers">Growers</a>
93 <a href="/leaderboard">Leaderboard</a>
94 </nav>
95 <nav aria-label="Take part">
96 <h2>Take part</h2>
97 <a href="/share">Share a skill</a>
98 <a href="/seeds">How Seeds work</a>
99 <a href="/connect">Connect over MCP</a>
100 <a href="/help">Help and setup prompts</a>
101 <a href="/guidelines">Guidelines and safety</a>
102 </nav>
103 <nav aria-label="Skillfarm">
104 <h2>Skillfarm</h2>
105 <a href="/privacy">Privacy</a>
106 <a href="/research">Research</a>
107 <a href="/guidelines#reporting">Report a problem</a>
108 <a href={`https://branchwell.ai/skillfarm/website/for${path}`} rel="noopener">Source</a>
109 </nav>
110 </div>
111 <div class="wrap footer-bottom">
112 <span>Skillfarm · Free to use · Seeds are status, not currency.</span>
113 </div>
114 </footer>
115);
116
117export const Page: FC<PageProps & { c: Ctx }> = ({ c, title, description, image, noindex, active, narrow, bare, children }) => {
118 const user = c.get('user');
119 const flash = c.get('flash');
120 const url = new URL(c.req.url);
121 const site = c.env.SITE_URL;
122 const fullTitle = title ? `${title} | Skillfarm` : 'Skillfarm: a curated list of agent skills';
123 const desc = description ?? DEFAULT_DESC;
124 const og = image ?? `${site}/img/og.png`;
125 return (
126 <html lang="en">
127 <head>
128 <meta charset="utf-8" />
129 <meta name="viewport" content="width=device-width, initial-scale=1" />
130 <title>{fullTitle}</title>
131 <meta name="description" content={desc} />
132 {noindex ? <meta name="robots" content="noindex" /> : null}
133 <link rel="canonical" href={`${site}${url.pathname}`} />
134 <meta property="og:type" content="website" />
135 <meta property="og:site_name" content="Skillfarm" />
136 <meta property="og:title" content={title ?? 'Skillfarm: a curated list of agent skills'} />
137 <meta property="og:description" content={desc} />
138 <meta property="og:url" content={`${site}${url.pathname}`} />
139 <meta property="og:image" content={og} />
140 <meta name="twitter:card" content="summary_large_image" />
141 <meta name="theme-color" content="#F6EFD9" />
142 <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
143 <link rel="icon" href="/favicon.ico" sizes="32x32" />
144 <link rel="apple-touch-icon" href="/img/apple-touch-icon.png" />
145 <link rel="preload" href="/fonts/fraunces-latin-soft-normal.woff2" as="font" type="font/woff2" crossorigin="" />
146 <link rel="preload" href="/fonts/figtree-latin-wght-normal.woff2" as="font" type="font/woff2" crossorigin="" />
147 <link rel="stylesheet" href={`/css/site.css?v=${VERSION}`} />
148 <script src={`/js/site.js?v=${VERSION}`} defer></script>
149 <link rel="stylesheet" href="/assets/visitor-odometer.v1.css" />
150 <script defer src="/assets/visitor-odometer.v1.js"></script>
151 <link rel="stylesheet" href="/no-orphans.css" />
152 <script src="/no-orphans.js" defer></script>
153 <script async src="https://www.googletagmanager.com/gtag/js?id=G-LB5W3LD2QL"></script>
154 <script src={`/js/ga.js?v=${VERSION}`} defer></script>
155 </head>
156 <body data-signed-in={user ? '1' : '0'}>
157 <a href="#main" class="skip">Skip to content</a>
158 {bare ? null : <Header user={user} active={active} path={url.pathname + url.search} />}
159 {flash ? (
160 <div class={`flash flash-${flash.kind}`} role="status">
161 <div class="wrap">{flash.text}</div>
162 </div>
163 ) : null}
164 <main id="main" class={narrow ? 'narrow' : ''}>
165 {children}
166 </main>
167 {bare ? null : <Footer path={url.pathname} />}
168 </body>
169 </html>
170 );
171};
172
173export function render(c: Ctx, props: PageProps, body: Child, status = 200) {
174 return c.html(html`<!doctype html>${(<Page c={c} {...props}>{body}</Page>)}`, status as 200);
175}