Branchwell

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

Raw 6.2 KB on a4acba8fed02ff053e24fa2ab137b32f1b601fa1
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 every major coding agent. 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 <nav class="wrap footer-links" aria-label="Footer">
80 <a href="https://branchwell.ai/skillfarm/research" rel="noopener">Research</a>
81 <span class="footer-dot" aria-hidden="true">·</span>
82 <a href={`https://branchwell.ai/skillfarm/website/for${path}`} rel="noopener">Source</a>
83 </nav>
84 </footer>
85);
86
87export const Page: FC<PageProps & { c: Ctx }> = ({ c, title, description, image, noindex, active, narrow, bare, children }) => {
88 const user = c.get('user');
89 const flash = c.get('flash');
90 const url = new URL(c.req.url);
91 const site = c.env.SITE_URL;
92 const fullTitle = title ? `${title} | Skillfarm` : 'Skillfarm: a curated list of agent skills';
93 const desc = description ?? DEFAULT_DESC;
94 const og = image ?? `${site}/img/og.png`;
95 return (
96 <html lang="en">
97 <head>
98 <meta charset="utf-8" />
99 <meta name="viewport" content="width=device-width, initial-scale=1" />
100 <title>{fullTitle}</title>
101 <meta name="description" content={desc} />
102 {noindex ? <meta name="robots" content="noindex" /> : null}
103 <link rel="canonical" href={`${site}${url.pathname}`} />
104 <meta property="og:type" content="website" />
105 <meta property="og:site_name" content="Skillfarm" />
106 <meta property="og:title" content={title ?? 'Skillfarm: a curated list of agent skills'} />
107 <meta property="og:description" content={desc} />
108 <meta property="og:url" content={`${site}${url.pathname}`} />
109 <meta property="og:image" content={og} />
110 <meta name="twitter:card" content="summary_large_image" />
111 <meta name="theme-color" content="#F6EFD9" />
112 <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
113 <link rel="icon" href="/favicon.ico" sizes="32x32" />
114 <link rel="apple-touch-icon" href="/img/apple-touch-icon.png" />
115 <link rel="preload" href="/fonts/fraunces-latin-soft-normal.woff2" as="font" type="font/woff2" crossorigin="" />
116 <link rel="preload" href="/fonts/figtree-latin-wght-normal.woff2" as="font" type="font/woff2" crossorigin="" />
117 <link rel="stylesheet" href={`/css/site.css?v=${VERSION}`} />
118 <script src={`/js/site.js?v=${VERSION}`} defer></script>
119 <script type="module" src={`/js/biolock-page.js?v=${VERSION}`}></script>
120 <link rel="stylesheet" href="/assets/visitor-odometer.v1.css" />
121 <script defer src="/assets/visitor-odometer.v1.js"></script>
122 <link rel="stylesheet" href="/no-orphans.css" />
123 <script src="/no-orphans.js" defer></script>
124 <script async src="https://www.googletagmanager.com/gtag/js?id=G-LB5W3LD2QL"></script>
125 <script src={`/js/ga.js?v=${VERSION}`} defer></script>
126 </head>
127 <body data-signed-in={user ? '1' : '0'}>
128 <a href="#main" class="skip">Skip to content</a>
129 {bare ? null : <Header user={user} active={active} path={url.pathname + url.search} />}
130 {flash ? (
131 <div class={`flash flash-${flash.kind}`} role="status">
132 <div class="wrap">{flash.text}</div>
133 </div>
134 ) : null}
135 <main id="main" class={narrow ? 'narrow' : ''}>
136 {children}
137 </main>
138 {bare ? null : <Footer path={url.pathname} />}
139 </body>
140 </html>
141 );
142};
143
144export function render(c: Ctx, props: PageProps, body: Child, status = 200) {
145 return c.html(html`<!doctype html>${(<Page c={c} {...props}>{body}</Page>)}`, status as 200);
146}