@profullstack/waitlist 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,13 +83,32 @@ Attributes: `dn` (the list; defaults to the page's host), `api` (default
83
83
  Any server with these two routes works (moshcoding.com runs them: double opt-in email,
84
84
  a list per domain in the owner's dashboard, `waitlist.signup` domain webhooks):
85
85
 
86
- - `POST /api/waitlist` `{ email, dn, ref? }` -> `{ ok, pending, already }` or `{ error }`
86
+ - `POST /api/waitlist` `{ email, dn, ref?, site?, bump? }` -> `{ ok, pending, already, referral? }` or `{ error }`;
87
+ `referral` is `{ code, link, position, total, referrals, bump }`
87
88
  - `GET /api/waitlist/stats?dn=&days=` -> `{ total, verified, days: [{ day, n }] }` (counts only)
89
+ - `GET /api/waitlist/referrals/leaderboard?dn=&limit=` -> `{ dn, updatedAt, entries: [{ rank, name, handle, referrals }] }`
90
+ (names are chosen handles or masked emails)
88
91
 
89
- Both send `Access-Control-Allow-Origin: *`.
92
+ All send `Access-Control-Allow-Origin: *`. A launch page is static, so the leaderboard
93
+ endpoint lives on the API host, not on the page's own host.
90
94
 
91
95
  MIT
92
96
 
97
+ ## Installable (PWA) and search pages (0.8)
98
+
99
+ Every site ships `site.webmanifest` (icons 192/512 + maskable, the search tabs as shortcuts),
100
+ `sw.js` (pages network-first with an offline copy, assets stale-while-revalidate; turn off
101
+ with `"pwa": false`), `opensearch.xml`, and the `search` plugin's static result pages.
102
+
103
+ Trending = (1 + net pit.world votes + a rank bonus) / (age in days + 2)^1.2; Recent = newest
104
+ first; Recommended = pit.world's own order. Search results are cached per (query, tab) in
105
+ `--cache`: daily for News/Videos/Live/Podcasts/Blogs/Social/All, weekly for the rest. The CLI
106
+ spaces searches `--search-gap-ms` apart (default 3100, under pit.world's 20/min per-IP limit),
107
+ so a first build of many sites takes about 45 s per site; later builds mostly hit the cache.
108
+
109
+ Analytics: `crawlproof` per site in `sites.json` sets that site's own CrawlProof id on every
110
+ page (home and search); without it Moshpit names report to the shared Moshpit project.
111
+
93
112
  ## A/B testing the look (0.3)
94
113
 
95
114
  Every built page runs one experiment by default, `waitlist-look-v1`: the page's own themed
@@ -101,7 +120,7 @@ The page reports one exposure a day; a signup is the conversion. Both go through
101
120
  waitlist API, which holds the CrawlProof token. Stop the experiment with a winner in
102
121
  CrawlProof and every page switches to it. Turn it off per site with `"ab": false`.
103
122
 
104
- ## Plugins (0.4; buyaday 0.6; book + promo 0.7)
123
+ ## Plugins (0.4; buyaday 0.6; book + promo 0.7; affiliate 0.9)
105
124
 
106
125
  Every page showcases all plugins by default. Pick per site in `sites.json`:
107
126
  `"plugins": ["form", "board"]` keeps only those, `"plugins": { "faq": false }` drops some.
@@ -112,6 +131,7 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
112
131
  | `stats` | who's waiting: a count and a signup chart |
113
132
  | `ab` | the look A/B test (see above) |
114
133
  | `faq` | visible questions and answers (the FAQPage JSON-LD stays) |
134
+ | `search` | every pit.world search tab (All, News, Videos, Live, Images, Music, Podcasts, Blogs, Social, Books, Scholar, Shopping, Places, MCPs) rendered at build time as static pages in the site's look: `/search/`, `/search/<tab>/`, plus `recent/` and `trending/` sorts. Each page has its own title, description, canonical, og.png, JSON-LD (CollectionPage + ItemList + BreadcrumbList) and is listed in `sitemap.xml`, `llms.txt` and `search.json`. Empty tabs get no page. Query: `searchQuery` per site, else three strong keywords |
115
135
  | `resources` | useful reading from our own search: `pit.world/api/search?q=<keywords>` at build time, cached in `--cache` (default `.waitlist-cache`), shown with summaries, saved as `resources.json` |
116
136
  | `board` | WWWThreads-style posts and replies, plus a compact thread on every resource and FAQ answer ([@profullstack/comments](https://www.npmjs.com/package/@profullstack/comments)); reading is open, posting needs **Sign in with CoinPay**; RSS of the posts |
117
137
  | `share` | a Share button on the board, also behind CoinPay sign-in |
@@ -119,6 +139,29 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
119
139
  | `buyaday` | `<pf-buy-a-day>` from [@profullstack/marketing-widgets](https://github.com/profullstack/marketing-widgets): the next free doors on [holi.days](https://holi.days.pit.world/calendars) calendars (ones matching the site's keywords first), baked in and refreshed live, every sale credited to this site with `?ref=<host>`. Nothing shows when the feed is down. `buyadayKeywords` / `buyadayLimit` in `sites.json` override the keywords and count (default 3) |
120
140
  | `book` | The Profullstack pitch (four solution lines) and `<book-a-call>`, our booking widget: open times from the OutreachGraph public calendar in the reader's own time zone, booked inline as a PairUX call. A plain link to the booking page without script. `"booking": {"handle": "chovy"}` picks the calendar |
121
141
  | `promo` | "More from the network": sister properties from the live `@profullstack/cross-promo` catalog, tagged `utm_medium=waitlist`. `"promoAudience": "developers"` (or a list) overrides the audience picked from the hierarchy |
142
+ | `affiliate` | Referrals (0.9). Every signup gets a personal link `https://<site>/?ref=<code>`, shown right after joining by `<pf-referral-share>` ("You are #X of Y, N people referred.", copy button, plain X/Bluesky/LinkedIn/email links) and in the confirmation email with a signed status page. A visitor who arrives with `?ref=` keeps a 30-day first-party, first-touch cookie `wl_ref`; their signup credits the referrer once they confirm. Each confirmed referral moves the referrer up `bumpPlaces`. A "Move up the list" section bakes `<pf-referral-leaderboard>` (handles or masked emails only). With `buyaday` on, a door sold to a referred visitor credits the referrer too (holi.days `ref=<code>.<site>`). See below |
143
+
144
+ ### Referrals (`affiliate`)
145
+
146
+ ```json
147
+ { "name": "comp.lang", "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10 } }
148
+ ```
149
+
150
+ All keys are optional (shown with their defaults); `"affiliate": { "enabled": false }` or
151
+ `"plugins": { "affiliate": false }` turns it off. The rules live on the API (moshcoding.com):
152
+ no self-referral (same normalized email: case, `+tags`, Gmail dots), one credit per referred
153
+ person per list, only confirmed signups count, at most 3 credited signups per hashed IP per
154
+ list per day (IPs are HMAC'd, never stored). Nothing here pays or promises money.
155
+
156
+ Snippet for any page on the same API:
157
+
158
+ ```html
159
+ <waitlist-form dn="comp.lang" bump="3"></waitlist-form>
160
+ <pf-referral-share bump="3"></pf-referral-share>
161
+ <pf-referral-leaderboard dn="comp.lang"></pf-referral-leaderboard>
162
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@profullstack/waitlist/src/index.js"></script>
163
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@profullstack/marketing-widgets/src/widgets.js"></script>
164
+ ```
122
165
 
123
166
  `keywords` (also the `<meta name="keywords">`) default to the name's labels plus the tagline's
124
167
  meaningful words; set `keywords` or `resourcesQuery` per site to steer the resources.
package/bin/waitlist.js CHANGED
@@ -21,6 +21,7 @@ flags:
21
21
  --max-age-hours <n> refresh cached search results older than this (default 20)
22
22
  --no-footers skip the webring + pit.world footers (offline builds)
23
23
  --no-images skip the PNG renders (og.png, icons)
24
+ --search-gap-ms <n> wait between pit.world searches (default 3100: under its 20/min per-IP limit)
24
25
 
25
26
  Every site field (seoTitle, description, summary, faq, image, imageAlt, keywords, sameAs,
26
27
  audience, lang, locale, themeColor, twitter, schema, ...) can be set per site in sites.json.
@@ -44,7 +45,7 @@ for (let i = 0; i < argv.length; i++) {
44
45
  } else pos.push(a);
45
46
  }
46
47
 
47
- const opts = { footers: flags.footers !== false, images: flags.images !== false, cacheDir: flags.cache || '.waitlist-cache', maxAgeMs: flags['max-age-hours'] ? Number(flags['max-age-hours']) * 3600_000 : undefined };
48
+ const opts = { footers: flags.footers !== false, images: flags.images !== false, cacheDir: flags.cache || '.waitlist-cache', maxAgeMs: flags['max-age-hours'] ? Number(flags['max-age-hours']) * 3600_000 : undefined, searchOpts: { gapMs: flags['search-gap-ms'] ? Number(flags['search-gap-ms']) : 3100 } };
48
49
  const pick = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
49
50
  if (cmd === 'build') {
50
51
  const s = await buildSite(pick({ name: flags.name, title: flags.title, tagline: flags.tagline, about: flags.about, points: flags.point, api: flags.api, host: flags.host, url: flags.url, image: flags.image, description: flags.description, theme: flags.theme, look: flags.look }), flags.out || `./${flags.name}`, opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/waitlist",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Email waitlist for any launch page: a <waitlist-form> web component, a live signup chart, and a static-site builder on @profullstack/css + @profullstack/charts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -51,7 +51,7 @@
51
51
  "@profullstack/footer": "^0.7.3",
52
52
  "@resvg/resvg-js": "^2.6.2",
53
53
  "@profullstack/comments": "^0.2.0",
54
- "@profullstack/marketing-widgets": "^0.1.0",
54
+ "@profullstack/marketing-widgets": "^0.2.0",
55
55
  "@profullstack/cross-promo": "^0.2.1"
56
56
  },
57
57
  "devDependencies": {
package/src/build.js CHANGED
@@ -3,7 +3,11 @@
3
3
  * for one name, ready for `c0mpute hosting publish <dir> --name <site>`.
4
4
  */
5
5
  import { mkdir, writeFile, copyFile, readFile, readdir } from 'node:fs/promises';
6
- import { pluginSet, keywordsFor, runPlugins, baseSlot } from './plugins.js';
6
+ import { pluginSet, keywordsFor, runPlugins, baseSlot, affiliateConfig } from './plugins.js';
7
+ import {
8
+ TABS, SORTS, tabPath, searchPageHtml, searchPageMeta, searchJson, searchLlms, manifestJson,
9
+ openSearchXml, serviceWorker, maskableIconSvg,
10
+ } from './search.js';
7
11
  import { createRequire } from 'node:module';
8
12
  import { createHash } from 'node:crypto';
9
13
  import { dirname, join } from 'node:path';
@@ -110,6 +114,7 @@ export function normalize(spec) {
110
114
  marquee: spec.marquee || `Welcome to ${name}! You are visitor #000${(name.length * 7919) % 9000 + 1000}. Sign the waitlist below!`,
111
115
  crawlproof: spec.crawlproof === undefined ? (moshpit ? MOSHPIT_STATS_SITE : null) : spec.crawlproof,
112
116
  plugins: pluginSet(spec.plugins),
117
+ affiliate: affiliateConfig(spec.affiliate),
113
118
  ab: spec.ab === false ? null : { ...DEFAULT_AB, ...(spec.ab || {}) },
114
119
  lang: spec.lang || 'en',
115
120
  locale: spec.locale || 'en_US',
@@ -133,36 +138,59 @@ export function normalize(spec) {
133
138
  s.summary = spec.summary || d.summary;
134
139
  s.imageAlt = spec.imageAlt || d.imageAlt;
135
140
  if (!s.plugins.has('ab')) s.ab = null;
141
+ if (!s.affiliate.enabled) s.plugins.delete('affiliate');
136
142
  if (!s.keywords.length) s.keywords = keywordsFor(s);
137
143
  s.resourcesQuery = spec.resourcesQuery || '';
144
+ s.searchQuery = spec.searchQuery || '';
145
+ s.pwa = spec.pwa !== false;
138
146
  s.faq = Array.isArray(spec.faq) && spec.faq.length ? spec.faq.map((f) => ({ q: f.q ?? f.question, a: f.a ?? f.answer })) : d.faq;
139
147
  return s;
140
148
  }
141
149
 
142
- /** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
143
- export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s) } = {}) {
144
- const points = s.points.length
145
- ? `<section class="stack" aria-labelledby="what"><h2 id="what">What's coming</h2><ul class="waitlist-points">${s.points.map((p) => `<li>${esc(p)}</li>`).join('')}</ul></section>`
146
- : '';
147
- const about = s.about ? `<p>${esc(s.about)}</p>` : '';
150
+ /**
151
+ * The page shell every page shares: look, A/B script, stylesheets, marquee,
152
+ * footers, scripts and the crawlproof tag. `head` is the page's own SEO head;
153
+ * `main` the inside of <main>.
154
+ */
155
+ export function shellHtml(s, { head, main, footers = '', slot = baseSlot(s) }) {
148
156
  return `<!doctype html>
149
157
  <html lang="${esc(s.lang)}" data-theme="${esc(s.theme)}" data-look="${esc(s.look)}">
150
158
  <head>
151
159
  <meta charset="utf-8">
152
160
  <meta name="viewport" content="width=device-width, initial-scale=1">
153
161
  ${s.ab ? abHeadScript(s.ab, s.look) : ''}
154
- ${headTags(s, { noindex })}
162
+ ${head}
155
163
  <link rel="stylesheet" href="assets/profullstack.css">
156
164
  <link rel="stylesheet" href="assets/looks.css">
157
165
  <link rel="stylesheet" href="assets/charts.css">
158
166
  <link rel="stylesheet" href="assets/waitlist.css">
159
- ${jsonLdTag(s)}
160
167
  ${slot.head.join('\n')}
161
168
  </head>
162
169
  <body class="waitlist-page">
163
170
  <div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
164
171
  <main class="container">
165
- <header class="waitlist-hero stack" data-space="lg">
172
+ ${main}
173
+ <p class="waitlist-meta">${s.moshpit ? `Also at <a href="${esc(s.nativeUrl)}">${esc(s.nativeUrl.replace(/\/$/, ''))}</a> on the Moshpit. ` : ''}One email when it opens, nothing else. Hosted on <a href="https://c0mpute.com/hosting">c0mpute</a>.</p>
174
+ </main>
175
+ <footer class="site-footer container"><p class="waitlist-meta">${esc(s.title)} · <a href="llms.txt">llms.txt</a>${s.searchLive ? ' · <a href="search/">search</a>' : ''}${s.moshpit ? ' · <a href="https://pit.world/directory">pit.world directory</a>' : ''}</p></footer>
176
+ ${footers}
177
+ <script src="assets/charts.global.js"></script>
178
+ <script type="module" src="assets/waitlist.js"></script>
179
+ ${slot.scripts.join('\n')}
180
+ ${s.pwa ? '<script>if("serviceWorker"in navigator){var m=document.querySelector(\'link[rel="manifest"]\');if(m)navigator.serviceWorker.register(new URL("sw.js",m.href)).catch(function(){})}</script>' : ''}
181
+ ${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
182
+ </body>
183
+ </html>
184
+ `;
185
+ }
186
+
187
+ /** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
188
+ export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s) } = {}) {
189
+ const points = s.points.length
190
+ ? `<section class="stack" aria-labelledby="what"><h2 id="what">What's coming</h2><ul class="waitlist-points">${s.points.map((p) => `<li>${esc(p)}</li>`).join('')}</ul></section>`
191
+ : '';
192
+ const about = s.about ? `<p>${esc(s.about)}</p>` : '';
193
+ const main = `<header class="waitlist-hero stack" data-space="lg">
166
194
  <p class="waitlist-kicker"><span class="badge">${esc(s.kicker)}</span></p>
167
195
  <h1>${esc(s.title)}</h1>
168
196
  <p class="waitlist-tagline">${esc(s.tagline)}</p>
@@ -175,18 +203,8 @@ ${slot.head.join('\n')}
175
203
  ${slot.cards.join('\n')}
176
204
  </div>
177
205
  ${s.plugins.has('faq') ? faqHtml(s, { comments: s.plugins.has('board') }) : ''}
178
- ${slot.sections.join('\n')}
179
- <p class="waitlist-meta">${s.moshpit ? `Also at <a href="${esc(s.nativeUrl)}">${esc(s.nativeUrl.replace(/\/$/, ''))}</a> on the Moshpit. ` : ''}One email when it opens, nothing else. Hosted on <a href="https://c0mpute.com/hosting">c0mpute</a>.</p>
180
- </main>
181
- <footer class="site-footer container"><p class="waitlist-meta">${esc(s.title)} · <a href="llms.txt">llms.txt</a>${s.moshpit ? ' · <a href="https://pit.world/directory">pit.world directory</a>' : ''}</p></footer>
182
- ${footers}
183
- <script src="assets/charts.global.js"></script>
184
- <script type="module" src="assets/waitlist.js"></script>
185
- ${slot.scripts.join('\n')}
186
- ${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
187
- </body>
188
- </html>
189
- `;
206
+ ${slot.sections.join('\n')}`;
207
+ return shellHtml(s, { head: `${headTags(s, { noindex })}\n${jsonLdTag(s)}`, main, footers, slot });
190
208
  }
191
209
 
192
210
  /** Square icon in the look's colors (takes a normalized spec or a bare name). */
@@ -218,7 +236,7 @@ export async function renderFooters(s, { fetchImpl = globalThis.fetch } = {}) {
218
236
  * Write the site for one spec into `out`. Returns the normalized spec.
219
237
  * `images: false` skips the PNG renders (og.png, icons), e.g. where @resvg/resvg-js cannot load.
220
238
  */
221
- export async function buildSite(spec, out, { footers = true, images = true, fetchImpl, cacheDir = null, maxAgeMs } = {}) {
239
+ export async function buildSite(spec, out, { footers = true, images = true, fetchImpl, cacheDir = null, maxAgeMs, searchOpts = {} } = {}) {
222
240
  const s = normalize(spec);
223
241
  await mkdir(join(out, 'assets'), { recursive: true });
224
242
  await mkdir(join(out, '.well-known'), { recursive: true });
@@ -237,22 +255,59 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
237
255
  await writeFile(join(out, 'og.png'), await svgToPng(og));
238
256
  await writeFile(join(out, 'assets', 'icon-192.png'), await svgToPng(icon, { width: 192 }));
239
257
  await writeFile(join(out, 'assets', 'icon-180.png'), await svgToPng(icon, { width: 180 }));
258
+ await writeFile(join(out, 'assets', 'icon-512.png'), await svgToPng(icon, { width: 512 }));
259
+ await writeFile(join(out, 'assets', 'icon-maskable-512.png'), await svgToPng(maskableIconSvg(s), { width: 512 }));
240
260
  }
241
261
  const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
242
- const { slot } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs });
262
+ const { slot, search } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts });
263
+ s.searchLive = Boolean(search?.live?.length);
243
264
  // Assets are cached by browsers and gateways (max-age 1 h), so a page must name the
244
265
  // exact build of every script and stylesheet it needs, or a new page runs old code.
245
266
  const ver = await versionAssets(out);
246
267
  await writeFile(join(out, 'index.html'), withAssetVersion(pageHtml(s, { footers: foot, slot }), ver));
247
268
  await writeFile(join(out, '404.html'), withAssetVersion(pageHtml(s, { footers: foot, noindex: true, slot }), ver));
269
+ const pages = s.searchLive ? await writeSearch(s, search, out, { footers: foot, slot, ver, images }) : [];
270
+ s.extraUrls = pages.map((p) => p.url);
271
+ await writeFile(join(out, 'site.webmanifest'), manifestJson(s, s.searchLive ? search : null));
272
+ await writeFile(join(out, 'opensearch.xml'), openSearchXml(s));
273
+ if (s.pwa) await writeFile(join(out, 'sw.js'), serviceWorker(ver));
248
274
  await writeFile(join(out, 'robots.txt'), robotsTxt(s));
249
- await writeFile(join(out, 'sitemap.xml'), sitemapXml(s));
250
- await writeFile(join(out, 'llms.txt'), llmsTxt(s));
275
+ await writeFile(join(out, 'sitemap.xml'), sitemapXml(s, pages));
276
+ await writeFile(join(out, 'llms.txt'), llmsTxt(s, { extra: s.searchLive ? searchLlms(s, search) : '' }));
251
277
  await writeFile(join(out, `${s.indexnowKey}.txt`), `${s.indexnowKey}\n`);
252
278
  await writeFile(join(out, '.well-known', 'openwebring.json'), JSON.stringify({ name: s.title, url: s.url, ring: 'profullstack', description: s.tagline }, null, 2) + '\n');
253
279
  return s;
254
280
  }
255
281
 
282
+ /**
283
+ * Write the static search pages: one per tab that has results, times each sort,
284
+ * plus an Open Graph card per tab and search.json. Returns the sitemap entries
285
+ * (the recommended view of each tab; the sorted views point their canonical at it).
286
+ */
287
+ async function writeSearch(s, search, out, { footers, slot, ver, images }) {
288
+ const pages = [];
289
+ // The waitlist form rides along on every search page; the home page's own sections do not.
290
+ const pageSlot = { ...slot, cards: [], sections: [] };
291
+ for (const t of search.live) {
292
+ const data = search.tabs[t.id];
293
+ for (const sort of SORTS) {
294
+ const { html, path } = searchPageHtml(s, search, t.id, sort.id, {
295
+ chrome: ({ head, body, spec }) => withAssetVersion(shellHtml(spec, { head, main: `${body}\n<section class="card stack" aria-label="Waitlist"><h2>Get ${esc(s.title)} when it opens</h2>${slot.hero.join('\n')}</section>`, footers, slot: pageSlot }), ver),
296
+ });
297
+ await mkdir(join(out, path), { recursive: true });
298
+ await writeFile(join(out, path, 'index.html'), html);
299
+ }
300
+ const m = searchPageMeta(s, t.id, data);
301
+ if (images) {
302
+ const card = ogSvg({ ...s, kicker: `Search · ${t.label}`, title: s.title, tagline: `${t.label}: ${data.query}`, button: 'Browse the results' });
303
+ await writeFile(join(out, tabPath(t.id), 'og.png'), await svgToPng(card));
304
+ }
305
+ pages.push({ url: m.url, lastmod: data.fetchedAt.slice(0, 10), image: m.image, changefreq: 'daily' });
306
+ }
307
+ await writeFile(join(out, 'search.json'), searchJson(s, search));
308
+ return pages;
309
+ }
310
+
256
311
  /** A short hash of everything in assets/; module imports between assets carry it too. */
257
312
  export async function versionAssets(out) {
258
313
  const dir = join(out, 'assets');
@@ -271,7 +326,7 @@ export async function versionAssets(out) {
271
326
 
272
327
  /** assets/x.css -> assets/x.css?v=<ver> in href/src attributes. */
273
328
  export function withAssetVersion(html, ver) {
274
- return html.replace(/((?:href|src)=")(assets\/[^"?#]+)(")/g, `$1$2?v=${ver}$3`);
329
+ return html.replace(/((?:href|src)=")((?:\.\.\/)*assets\/[^"?#]+)(")/g, `$1$2?v=${ver}$3`);
275
330
  }
276
331
 
277
332
  /** Build many: specs is an array; each lands in `${outRoot}/${name}`. */
package/src/index.js CHANGED
@@ -31,6 +31,29 @@ export function refFrom(href) {
31
31
  }
32
32
  }
33
33
 
34
+ /** The first-party cookie that remembers a referral code (first touch, 30 days). */
35
+ export const REF_COOKIE = 'wl_ref';
36
+
37
+ /** A referral code from a cookie string, or null. */
38
+ export function refFromCookie(cookie) {
39
+ const m = String(cookie ?? '').match(/(?:^|;\s*)wl_ref=([A-Za-z0-9]{6,16})(?:;|$)/);
40
+ return m ? m[1].toLowerCase() : null;
41
+ }
42
+
43
+ /**
44
+ * The referral code in force for this visit: a first-touch cookie wins; else
45
+ * ?ref= on this URL, which is then remembered for 30 days. Null without either.
46
+ */
47
+ export function captureRef(doc = globalThis.document, href = globalThis.location?.href) {
48
+ const kept = refFromCookie(doc?.cookie);
49
+ if (kept) return kept;
50
+ const ref = href ? refFrom(href) : null;
51
+ if (ref && doc && /^[A-Za-z0-9]{6,16}$/.test(ref)) {
52
+ doc.cookie = `${REF_COOKIE}=${ref.toLowerCase()}; Max-Age=${30 * 86400}; Path=/; SameSite=Lax${String(href).startsWith('https:') ? '; Secure' : ''}`;
53
+ }
54
+ return ref;
55
+ }
56
+
34
57
  /** The message to show for an API answer. */
35
58
  export function messageFor(res, email) {
36
59
  if (res && res.ok) {
@@ -72,14 +95,23 @@ export async function reportExposure({ api = DEFAULT_API, dn, fetchImpl = global
72
95
  }
73
96
  }
74
97
 
75
- export async function join({ email, dn, ref = null, api = DEFAULT_API, fetchImpl = globalThis.fetch, ab = abContext() }) {
98
+ /**
99
+ * POST one signup. `site` is this page's origin (so the referral link points at the
100
+ * host people reach, e.g. the pit.world relay) and `bump` the places one confirmed
101
+ * referral is worth on this site. The answer carries `referral` when the API has it.
102
+ */
103
+ export async function join({ email, dn, ref = null, api = DEFAULT_API, fetchImpl = globalThis.fetch, ab = abContext(), site = null, bump = null }) {
76
104
  const clean = cleanEmail(email);
77
105
  if (!clean) return { ok: false, status: 400, error: "That doesn't look like an email." };
106
+ const payload = { email: clean, dn, ref };
107
+ if (site) payload.site = site;
108
+ if (bump !== null && bump !== undefined && bump !== '') payload.bump = Number(bump);
109
+ if (ab) payload.ab = ab;
78
110
  try {
79
111
  const res = await fetchImpl(new URL('/api/waitlist', api).href, {
80
112
  method: 'POST',
81
113
  headers: { 'content-type': 'application/json' },
82
- body: JSON.stringify(ab ? { email: clean, dn, ref, ab } : { email: clean, dn, ref }),
114
+ body: JSON.stringify(payload),
83
115
  });
84
116
  const body = await res.json().catch(() => ({}));
85
117
  return { ...body, ok: Boolean(res.ok && body.ok), status: res.status };
@@ -110,6 +142,7 @@ export class WaitlistForm extends HTMLElementBase {
110
142
  if (this.dataset.ready) return;
111
143
  this.dataset.ready = '1';
112
144
  reportExposure({ api: this.getAttribute('api') || DEFAULT_API, dn: this.getAttribute('dn') || location.hostname });
145
+ captureRef();
113
146
  const id = `wl-${Math.random().toString(36).slice(2, 8)}`;
114
147
  this.innerHTML = `
115
148
  <form class="stack waitlist-form" novalidate>
@@ -140,8 +173,10 @@ export class WaitlistForm extends HTMLElementBase {
140
173
  const res = await join({
141
174
  email,
142
175
  dn: this.getAttribute('dn') || location.hostname,
143
- ref: refFrom(location.href),
176
+ ref: captureRef(),
144
177
  api: this.getAttribute('api') || DEFAULT_API,
178
+ site: location.origin,
179
+ bump: this.getAttribute('bump'),
145
180
  });
146
181
  say(messageFor(res, email));
147
182
  button.disabled = false;
package/src/plugins.js CHANGED
@@ -12,16 +12,19 @@
12
12
  * calendar, PairUX call). `"booking": {"handle": "chovy"}` picks the calendar.
13
13
  * promo "More from the network": sister properties from @profullstack/cross-promo.
14
14
  * `"promoAudience": "developers"` (or a list) picks who the reader is.
15
+ * affiliate referral links, place bumps and a leaderboard (`"affiliate": {...}`, see
16
+ * affiliateConfig); door sales credit the referrer when buyaday is on.
15
17
  */
16
18
  import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises';
17
19
  import { createRequire } from 'node:module';
18
20
  import { createHash } from 'node:crypto';
19
21
  import { dirname, join } from 'node:path';
20
22
  import { esc } from './seo.js';
23
+ import { fetchSearch, searchCardHtml } from './search.js';
21
24
 
22
25
  const require = createRequire(import.meta.url);
23
26
 
24
- export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo'];
27
+ export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo', 'affiliate'];
25
28
 
26
29
  /** Resolve a site's `plugins` setting to a Set (default: all of them). */
27
30
  export function pluginSet(setting) {
@@ -31,6 +34,53 @@ export function pluginSet(setting) {
31
34
  return on;
32
35
  }
33
36
 
37
+ /**
38
+ * The `affiliate` plugin's settings from sites.json:
39
+ *
40
+ * "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10 }
41
+ *
42
+ * bumpPlaces is how many places one confirmed referral moves someone up (0..50).
43
+ */
44
+ export function affiliateConfig(raw) {
45
+ const a = raw && typeof raw === 'object' ? raw : {};
46
+ const int = (v, d, lo, hi) => (Number.isFinite(Number(v)) && v !== null && v !== '' ? Math.min(Math.max(Math.floor(Number(v)), lo), hi) : d);
47
+ return {
48
+ enabled: raw === false ? false : a.enabled !== false,
49
+ bumpPlaces: int(a.bumpPlaces, 3, 0, 50),
50
+ leaderboard: a.leaderboard !== false,
51
+ leaderboardLimit: int(a.leaderboardLimit, 10, 1, 100),
52
+ };
53
+ }
54
+
55
+ /**
56
+ * Copy the @profullstack/marketing-widgets browser files FLAT into assets/ (as
57
+ * mw-widgets.js + mw-core.js: versionAssets reads assets/ and would EISDIR on a
58
+ * subfolder, and assets/core.js is already the comments package's). Once per build.
59
+ */
60
+ async function copyMarketingWidgets(mw, out, slot) {
61
+ if (slot._mw) return;
62
+ slot._mw = true;
63
+ const core = await readFile(mw.assetPath.core, 'utf8');
64
+ const widgets = (await readFile(mw.assetPath.widgets, 'utf8')).replace(/from '\.\/core\.js'/, "from './mw-core.js'");
65
+ await writeFile(join(out, 'assets', 'mw-core.js'), core);
66
+ await writeFile(join(out, 'assets', 'mw-widgets.js'), widgets);
67
+ slot.scripts.push('<script type="module" src="assets/mw-widgets.js"></script>');
68
+ }
69
+
70
+ /** The affiliate section: how referrals work, then the top referrers (baked, refreshed live). */
71
+ export async function affiliateHtml(s, { fetchImpl } = {}) {
72
+ const a = s.affiliate;
73
+ const mw = await import('@profullstack/marketing-widgets');
74
+ const how = a.bumpPlaces > 0
75
+ ? `Everyone who joins gets a personal link. Each friend who joins through yours and confirms their email moves you up ${a.bumpPlaces} ${a.bumpPlaces === 1 ? 'place' : 'places'}.`
76
+ : 'Everyone who joins gets a personal link. Friends who join through yours and confirm their email put you on the board.';
77
+ const board = a.leaderboard ? await mw.referralLeaderboardHtml({ dn: s.dn, api: s.api, limit: a.leaderboardLimit, fetchImpl }) : '';
78
+ return `<section class="stack waitlist-affiliate" aria-labelledby="referrals"><h2 id="referrals">Move up the list</h2>
79
+ <p>${esc(how)}</p>
80
+ ${board}
81
+ </section>`;
82
+ }
83
+
34
84
  const STOP = new Set('a an and are as at be by for from has have in into is it its of on or that the this to was we with you your our not yet will one all any get it\'s now new site'.split(' '));
35
85
 
36
86
  /** Keywords for a site: its own list, else the name's labels and the tagline's meaningful words. */
@@ -101,10 +151,13 @@ export function baseSlot(s) {
101
151
  const on = s.plugins || pluginSet();
102
152
  const slot = { head: [], hero: [], cards: [], sections: [], scripts: [] };
103
153
  if (on.has('form')) {
104
- slot.hero.push(`<waitlist-form dn="${esc(s.dn)}" api="${esc(s.api)}" button="${esc(s.button)}">
154
+ const aff = on.has('affiliate') && s.affiliate;
155
+ slot.hero.push(`<waitlist-form dn="${esc(s.dn)}" api="${esc(s.api)}" button="${esc(s.button)}"${aff ? ` bump="${aff.bumpPlaces}"` : ''}>
105
156
  <form class="stack" method="post" action="${esc(s.api)}/api/waitlist"><label for="wl-email">Email</label>
106
157
  <div class="field-group"><input id="wl-email" name="email" type="email" autocomplete="email" required><button type="submit">${esc(s.button)}</button></div></form>
107
158
  </waitlist-form>`);
159
+ // Shown after a signup: place on the list, personal link, copy + share links.
160
+ if (aff) slot.hero.push(`<pf-referral-share bump="${aff.bumpPlaces}"></pf-referral-share>`);
108
161
  }
109
162
  if (on.has('stats')) {
110
163
  slot.cards.push(`<section class="card stack" aria-labelledby="count"><h2 id="count">Who's waiting</h2>
@@ -114,12 +167,21 @@ export function baseSlot(s) {
114
167
  }
115
168
 
116
169
  /** Everything the plugins add to one page: { head, hero, cards, sections, scripts } and files to write. */
117
- export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {}) {
170
+ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts = {} } = {}) {
118
171
  const on = s.plugins;
119
172
  const slot = baseSlot(s);
120
173
  let res = null;
174
+ let search = null;
175
+ if (on.has('search')) {
176
+ search = await fetchSearch(s, { ...(fetchImpl ? { fetchImpl } : {}), cacheDir, ...(maxAgeMs ? { maxAgeMs } : {}), ...searchOpts });
177
+ slot.cards.push(searchCardHtml(s, search));
178
+ }
121
179
  if (on.has('resources')) {
122
- res = await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
180
+ const web = search?.tabs?.web;
181
+ // The All tab already searched the same words: reuse it instead of searching again.
182
+ res = web?.results?.length && !s.resourcesQuery
183
+ ? { query: web.query, fetchedAt: web.fetchedAt, results: web.results.slice(0, 8).map((r) => ({ url: r.url, title: r.title, summary: r.summary || '', host: r.host })) }
184
+ : await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
123
185
  slot.sections.push(resourcesHtml(s, res, { comments: on.has('board'), share: on.has('share') }));
124
186
  if (res.results.length) await writeFile(join(out, 'resources.json'), JSON.stringify(res, null, 2) + '\n');
125
187
  }
@@ -135,17 +197,22 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {})
135
197
  // @profullstack/marketing-widgets: sell holi.days doors, credited to this site.
136
198
  // Offers are baked in (no script needed, crawlers read them); the copied script
137
199
  // refreshes them live so taken doors drop off. An empty feed renders nothing.
200
+ // With affiliate on, a door sold to a referred visitor credits the referrer too
201
+ // (holi.days ref = <code>.<site>, from ?ref or the wl_ref cookie).
138
202
  const mw = await import('@profullstack/marketing-widgets');
139
- const html = await mw.buyADayHtml({ ref: s.host, keywords: s.buyadayKeywords || keywordsFor(s), limit: s.buyadayLimit || 3, fetchImpl });
203
+ const html = await mw.buyADayHtml({ ref: s.host, keywords: s.buyadayKeywords || keywordsFor(s), limit: s.buyadayLimit || 3, fetchImpl, referrerCookie: on.has('affiliate') });
140
204
  if (html.includes('pf-mw-offer')) {
141
- const core = await readFile(mw.assetPath.core, 'utf8');
142
- const widgets = (await readFile(mw.assetPath.widgets, 'utf8')).replace(/from '\.\/core\.js'/, "from './mw-core.js'");
143
- await writeFile(join(out, 'assets', 'mw-core.js'), core);
144
- await writeFile(join(out, 'assets', 'mw-widgets.js'), widgets);
205
+ await copyMarketingWidgets(mw, out, slot);
145
206
  slot.sections.push(`<section class="stack" aria-label="Buy a day">${html}</section>`);
146
- slot.scripts.push('<script type="module" src="assets/mw-widgets.js"></script>');
147
207
  }
148
208
  }
209
+ if (on.has('affiliate')) {
210
+ // Referral links, place bumps and a leaderboard (@profullstack/marketing-widgets
211
+ // on moshcoding's /api/waitlist/referrals/*). The share panel sits under the form.
212
+ const mw = await import('@profullstack/marketing-widgets');
213
+ await copyMarketingWidgets(mw, out, slot);
214
+ slot.sections.push(await affiliateHtml(s, { fetchImpl }));
215
+ }
149
216
  if (on.has('book')) {
150
217
  await copyFile(join(dirname(new URL(import.meta.url).pathname), 'book.js'), join(out, 'assets', 'book.js'));
151
218
  slot.sections.push(bookHtml(s));
@@ -158,7 +225,7 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {})
158
225
  await writeFile(join(out, 'feed.json'), f.json);
159
226
  slot.head.push(`<link rel="alternate" type="application/rss+xml" title="${esc(s.title)}" href="feed.xml">`, `<link rel="alternate" type="application/feed+json" title="${esc(s.title)}" href="feed.json">`);
160
227
  }
161
- return { slot, resources: res };
228
+ return { slot, resources: res, search };
162
229
  }
163
230
 
164
231
  // --- book: the Profullstack pitch + our booking widget ------------------------
package/src/search.js ADDED
@@ -0,0 +1,404 @@
1
+ /**
2
+ * The `search` plugin: every pit.world search tab (All, News, Videos, Live, ...)
3
+ * for the site's own keywords, rendered as static pages in the site's look at
4
+ * build time (server-side, no client fetch), so crawlers and answer engines read
5
+ * the results:
6
+ *
7
+ * /search/ All, recommended order (pit.world's own, vote-reranked)
8
+ * /search/<tab>/ one tab
9
+ * /search/<tab>/recent/ newest first
10
+ * /search/<tab>/trending/ votes + rank, decayed by age
11
+ *
12
+ * Every page has its own title, description, canonical, Open Graph card (og.png
13
+ * per tab), JSON-LD (CollectionPage + ItemList + BreadcrumbList) and is listed in
14
+ * sitemap.xml, llms.txt and search.json. Tabs that come back empty get no page.
15
+ * Results are cached on disk per (query, tab), so the daily rebuild searches at
16
+ * most once a day per tab (slow-moving tabs once a week), paced under pit.world's
17
+ * per-IP limit. Nothing here throws: a failed tab keeps its last good results.
18
+ */
19
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
20
+ import { createHash } from 'node:crypto';
21
+ import { join } from 'node:path';
22
+ import { esc, clip, headTags, paletteFor } from './seo.js';
23
+ import { keywordsFor } from './plugins.js';
24
+
25
+ const H = 3600_000;
26
+
27
+ /** The tabs, in pit.world's order. `maxAge` is how long a cached tab is good for at least. */
28
+ export const TABS = [
29
+ { id: 'web', label: 'All', type: 'WebPage', maxAge: 20 * H },
30
+ { id: 'news', label: 'News', type: 'NewsArticle', maxAge: 20 * H },
31
+ { id: 'videos', label: 'Videos', type: 'VideoObject', maxAge: 20 * H },
32
+ { id: 'live', label: 'Live', type: 'VideoObject', maxAge: 20 * H },
33
+ { id: 'images', label: 'Images', type: 'ImageObject', maxAge: 144 * H },
34
+ { id: 'music', label: 'Music', type: 'MusicRecording', maxAge: 144 * H },
35
+ { id: 'podcasts', label: 'Podcasts', type: 'PodcastSeries', maxAge: 20 * H },
36
+ { id: 'blogs', label: 'Blogs', type: 'BlogPosting', maxAge: 20 * H },
37
+ { id: 'social', label: 'Social', type: 'SocialMediaPosting', maxAge: 20 * H },
38
+ { id: 'books', label: 'Books', type: 'Book', maxAge: 144 * H },
39
+ { id: 'scholar', label: 'Scholar', type: 'ScholarlyArticle', maxAge: 144 * H },
40
+ { id: 'shopping', label: 'Shopping', type: 'Product', maxAge: 144 * H },
41
+ { id: 'places', label: 'Places', type: 'Place', maxAge: 144 * H },
42
+ { id: 'mcps', label: 'MCPs', type: 'SoftwareApplication', maxAge: 144 * H },
43
+ ];
44
+
45
+ export const SORTS = [
46
+ { id: 'recommended', label: 'Recommended' },
47
+ { id: 'recent', label: 'Recent' },
48
+ { id: 'trending', label: 'Trending' },
49
+ ];
50
+
51
+ const UA = '@profullstack/waitlist (+https://github.com/profullstack/waitlist)';
52
+
53
+ /** Path of a tab (and sort) under the site root: '' | 'search/' | 'search/news/recent/'. */
54
+ export function tabPath(tab, sort = 'recommended') {
55
+ const base = tab === 'web' ? 'search/' : `search/${tab}/`;
56
+ return sort === 'recommended' ? base : `${base}${sort}/`;
57
+ }
58
+
59
+ /** Words that make a poor search on their own: Usenet hierarchy labels and filler. */
60
+ const WEAK = new Set(['comp', 'alt', 'sci', 'rec', 'soc', 'talk', 'misc', 'news', 'whatever', 'yeah', 'pit', 'agent', 'indie', 'from', 'since', 'every', 'way', 'what', 'who', 'how', 'out', 'one', 'still', 'more', 'less', 'just', 'like', 'about']);
61
+
62
+ /** The query every tab searches: searchQuery, else resourcesQuery, else three strong keywords. */
63
+ export function searchQuery(s) {
64
+ if (s.searchQuery || s.resourcesQuery) return s.searchQuery || s.resourcesQuery;
65
+ const kw = keywordsFor(s);
66
+ const strong = kw.filter((w) => !WEAK.has(w));
67
+ return (strong.length ? strong : kw).slice(0, 3).join(' ');
68
+ }
69
+
70
+ function safeUrl(u, base) {
71
+ try {
72
+ const url = new URL(String(u || ''), base);
73
+ return /^https?:$/.test(url.protocol) ? url.href : null;
74
+ } catch { return null; }
75
+ }
76
+
77
+ /** One API hit -> the fields we render. null when it has no safe URL. */
78
+ export function normalizeHit(x) {
79
+ const url = safeUrl(x?.url);
80
+ if (!url || !/^https?:\/\//.test(String(x.url))) return null;
81
+ const str = (v, n) => (v == null || v === '' ? undefined : clip(String(v).replace(/\s+/g, ' '), n));
82
+ const thumb = x.thumbnail ? safeUrl(x.thumbnail, 'https://pit.world/') : null;
83
+ const hit = {
84
+ url,
85
+ title: str(x.title, 160) || url,
86
+ host: str(x.host, 80) || new URL(url).hostname.replace(/^www\./, ''),
87
+ summary: str(x.description || x.snippet || x.about, 300),
88
+ thumbnail: thumb && thumb.startsWith('https:') ? thumb : undefined,
89
+ date: str(x.date, 40),
90
+ duration: str(x.duration, 20),
91
+ channel: str(x.channel, 80),
92
+ author: str(x.author, 160),
93
+ extra: str(x.extra, 80),
94
+ };
95
+ for (const k of Object.keys(hit)) if (hit[k] === undefined) delete hit[k];
96
+ return hit;
97
+ }
98
+
99
+ let lastCall = 0;
100
+ const sleepReal = (ms) => new Promise((r) => setTimeout(r, ms));
101
+
102
+ /**
103
+ * One tab's results for a site: { tab, query, fetchedAt, provider, results }.
104
+ * Cached on disk by (query, tab); a failed search returns the stale copy, or no results.
105
+ */
106
+ export async function fetchTab(s, tab, {
107
+ fetchImpl = globalThis.fetch, cacheDir = null, maxAgeMs = 20 * H, now = Date.now(), n = 20,
108
+ endpoint = 'https://pit.world/api/search', gapMs = 0, sleep = sleepReal,
109
+ } = {}) {
110
+ const t = TABS.find((x) => x.id === tab) || TABS[0];
111
+ const q = searchQuery(s);
112
+ const empty = { tab: t.id, query: q, fetchedAt: new Date(now).toISOString(), provider: null, results: [] };
113
+ if (!q) return empty;
114
+ const key = createHash('sha256').update(`${q}\0${t.id}`).digest('hex').slice(0, 16);
115
+ const cacheFile = cacheDir ? join(cacheDir, `search-${key}.json`) : null;
116
+ let stale = null;
117
+ if (cacheFile) {
118
+ try {
119
+ const c = JSON.parse(await readFile(cacheFile, 'utf8'));
120
+ if (now - Date.parse(c.fetchedAt) < Math.max(maxAgeMs, t.maxAge)) return c;
121
+ stale = c;
122
+ } catch { /* not cached */ }
123
+ }
124
+ let out = null;
125
+ for (let attempt = 0; attempt < 3 && !out; attempt++) {
126
+ const wait = lastCall + gapMs - Date.now();
127
+ if (wait > 0) await sleep(wait);
128
+ lastCall = Date.now();
129
+ try {
130
+ const r = await fetchImpl(`${endpoint}?q=${encodeURIComponent(q)}&t=${t.id}&n=${n}`, { headers: { accept: 'application/json', 'user-agent': UA }, signal: AbortSignal.timeout(30000) });
131
+ if (r.status === 429) {
132
+ const ra = Number(r.headers?.get?.('retry-after')) || 30;
133
+ await sleep(Math.min(ra, 60) * 1000);
134
+ continue;
135
+ }
136
+ if (!r.ok) break;
137
+ const body = await r.json();
138
+ if (!Array.isArray(body.results)) break;
139
+ const seen = new Set();
140
+ const results = [...(t.id === 'web' ? body.featured || [] : []), ...body.results]
141
+ .map(normalizeHit)
142
+ .filter((h) => h && !seen.has(h.url) && seen.add(h.url));
143
+ out = { tab: t.id, query: q, fetchedAt: new Date(now).toISOString(), provider: body.provider || null, results };
144
+ } catch {
145
+ break;
146
+ }
147
+ }
148
+ if (!out) return stale || empty;
149
+ if (!out.results.length && stale?.results?.length) return stale;
150
+ if (cacheFile) { await mkdir(cacheDir, { recursive: true }); await writeFile(cacheFile, JSON.stringify(out, null, 2)); }
151
+ return out;
152
+ }
153
+
154
+ /** pit.world vote tallies for result URLs: Map url -> { up, down, score }. Never throws. */
155
+ export async function fetchVotes(urls, { fetchImpl = globalThis.fetch, endpoint = 'https://pit.world/api/votes' } = {}) {
156
+ const out = new Map();
157
+ const list = [...new Set(urls)];
158
+ for (let i = 0; i < list.length; i += 100) {
159
+ const chunk = list.slice(i, i + 100);
160
+ try {
161
+ const qs = chunk.map((u) => `item=${encodeURIComponent(`result:${u}`)}`).join('&');
162
+ const r = await fetchImpl(`${endpoint}?${qs}`, { headers: { accept: 'application/json', 'user-agent': UA }, signal: AbortSignal.timeout(15000) });
163
+ if (!r.ok) continue;
164
+ const body = await r.json();
165
+ (body.items || []).forEach((it, j) => {
166
+ const u = chunk[j];
167
+ if (u && (it.up || it.down)) out.set(u, { up: it.up | 0, down: it.down | 0, score: Number(it.score) || 0 });
168
+ });
169
+ } catch { /* votes are a bonus */ }
170
+ }
171
+ return out;
172
+ }
173
+
174
+ /** A hit's date as ms, or null. A bare year counts as Jan 1 of that year. */
175
+ export function hitTime(h) {
176
+ if (!h?.date) return null;
177
+ const d = String(h.date).trim();
178
+ if (/^\d{4}$/.test(d)) return Date.UTC(Number(d), 0, 1);
179
+ const t = Date.parse(d);
180
+ return Number.isFinite(t) ? t : null;
181
+ }
182
+
183
+ /**
184
+ * Order hits: recommended keeps pit.world's order (already vote-reranked);
185
+ * recent is newest first (undated last, in their order); trending is
186
+ * (1 + net votes + rank bonus) / (age in days + 2)^1.2, so new and voted-up rise.
187
+ */
188
+ export function sortHits(hits, sort, votes = new Map(), now = Date.now()) {
189
+ const list = hits.map((h, i) => ({ h, i }));
190
+ if (sort === 'recent') {
191
+ return list.sort((a, b) => (hitTime(b.h) ?? -Infinity) - (hitTime(a.h) ?? -Infinity) || a.i - b.i).map((x) => x.h);
192
+ }
193
+ if (sort === 'trending') {
194
+ const n = hits.length || 1;
195
+ const score = ({ h, i }) => {
196
+ const v = votes.get(h.url);
197
+ const points = 1 + (v ? v.up - v.down : 0) + (2 * (n - i)) / n;
198
+ const t = hitTime(h);
199
+ const days = t == null ? 365 : Math.max(0, (now - t) / (24 * H));
200
+ return points / (days + 2) ** 1.2;
201
+ };
202
+ return list.map((x) => ({ ...x, s: score(x) })).sort((a, b) => b.s - a.s || a.i - b.i).map((x) => x.h);
203
+ }
204
+ return hits.slice();
205
+ }
206
+
207
+ /** Fetch every tab (and the votes on their results) for a site. */
208
+ export async function fetchSearch(s, opts = {}) {
209
+ const tabs = {};
210
+ for (const t of TABS) tabs[t.id] = await fetchTab(s, t.id, opts);
211
+ const urls = Object.values(tabs).flatMap((d) => d.results.map((r) => r.url));
212
+ const votes = await fetchVotes(urls, opts);
213
+ return { query: searchQuery(s), tabs, votes, live: TABS.filter((t) => tabs[t.id].results.length) };
214
+ }
215
+
216
+ function fmtDate(h) {
217
+ const t = hitTime(h);
218
+ if (t == null) return h.date || '';
219
+ return /^\d{4}$/.test(h.date) ? h.date : new Date(t).toISOString().slice(0, 10);
220
+ }
221
+
222
+ function hitHtml(h, tab, v) {
223
+ const meta = [h.host, h.author, h.channel, fmtDate(h), h.duration, h.extra].filter(Boolean).map(esc).join(' · ');
224
+ const voted = v ? ` <span class="badge" title="pit.world votes">▲ ${v.up - v.down}</span>` : '';
225
+ if (tab === 'images') {
226
+ return `<li class="card wl-hit wl-hit-image"><a href="${esc(h.url)}" rel="noopener">${h.thumbnail ? `<img src="${esc(h.thumbnail)}" alt="${esc(h.title)}" loading="lazy" decoding="async" referrerpolicy="no-referrer">` : ''}<span>${esc(h.title)}</span></a><small class="muted">${esc(h.host)}</small></li>`;
227
+ }
228
+ const thumb = h.thumbnail ? `<img class="wl-thumb" src="${esc(h.thumbnail)}" alt="" loading="lazy" decoding="async" referrerpolicy="no-referrer" width="96" height="96">` : '';
229
+ return `<li class="card wl-hit">${thumb}<div class="stack" data-space="xs"><a href="${esc(h.url)}" rel="noopener"><strong>${esc(h.title)}</strong></a>${voted}<small class="muted">${meta}</small>${h.summary ? `<p>${esc(h.summary)}</p>` : ''}</div></li>`;
230
+ }
231
+
232
+ /** The SEO fields of one search page. */
233
+ export function searchPageMeta(s, tabId, data, sort = 'recommended') {
234
+ const t = TABS.find((x) => x.id === tabId);
235
+ const q = data.query;
236
+ const n = data.results.length;
237
+ const url = `${s.url}${tabPath(tabId)}`;
238
+ const what = tabId === 'web' ? 'results' : `${t.label.toLowerCase()} results`;
239
+ const top = data.results.slice(0, 3).map((r) => r.title).join('; ');
240
+ return {
241
+ url,
242
+ pageUrl: `${s.url}${tabPath(tabId, sort)}`,
243
+ h1: tabId === 'web' ? `${s.title} search: ${q}` : `${t.label} on ${s.title}: ${q}`,
244
+ seoTitle: clip(tabId === 'web' ? `${q}: search ${s.title}` : `${q}: ${t.label} on ${s.title}`, 70),
245
+ description: clip(`${n} ${what} for "${q}" on ${s.title}, from pit.world search, updated daily. ${top}`, 160),
246
+ answer: `${s.title} lists the top ${n} ${what} for "${q}" from pit.world search, refreshed every day (last updated ${data.fetchedAt.slice(0, 10)}). Sort them by recommended, most recent or trending.`,
247
+ image: `${url}og.png`,
248
+ imageAlt: `${t.label} results for ${q} on ${s.title}`,
249
+ };
250
+ }
251
+
252
+ /** JSON-LD for one search page: CollectionPage + ItemList + BreadcrumbList. */
253
+ export function searchJsonLd(s, tabId, data, hits, m) {
254
+ const t = TABS.find((x) => x.id === tabId);
255
+ const item = (h) => {
256
+ const o = { '@type': t.type, name: h.title, url: h.url };
257
+ if (h.summary) o.description = h.summary;
258
+ const time = hitTime(h);
259
+ if (time != null) o[t.type === 'VideoObject' ? 'uploadDate' : 'datePublished'] = new Date(time).toISOString().slice(0, 10);
260
+ if (h.thumbnail) o[t.type === 'ImageObject' ? 'contentUrl' : t.type === 'VideoObject' ? 'thumbnailUrl' : 'image'] = h.thumbnail;
261
+ if (h.author) o.author = { '@type': 'Person', name: h.author };
262
+ return o;
263
+ };
264
+ const crumbs = [{ name: s.title, url: s.url }, { name: 'Search', url: `${s.url}search/` }];
265
+ if (tabId !== 'web') crumbs.push({ name: t.label, url: m.url });
266
+ const graph = [
267
+ { '@type': 'CollectionPage', '@id': `${m.url}#page`, url: m.url, name: m.seoTitle, description: m.description, inLanguage: s.lang, dateModified: data.fetchedAt, isPartOf: { '@type': 'WebSite', '@id': `${s.url}#website`, name: s.title, url: s.url }, primaryImageOfPage: { '@type': 'ImageObject', url: m.image }, about: data.query, mainEntity: { '@id': `${m.url}#list` } },
268
+ { '@type': 'ItemList', '@id': `${m.url}#list`, name: m.h1, numberOfItems: hits.length, itemListOrder: 'https://schema.org/ItemListOrderDescending', itemListElement: hits.map((h, i) => ({ '@type': 'ListItem', position: i + 1, url: h.url, item: item(h) })) },
269
+ { '@type': 'BreadcrumbList', itemListElement: crumbs.map((c, i) => ({ '@type': 'ListItem', position: i + 1, name: c.name, item: c.url })) },
270
+ ];
271
+ return `<script type="application/ld+json">${JSON.stringify({ '@context': 'https://schema.org', '@graph': graph }).replace(/</g, '\\u003c')}</script>`;
272
+ }
273
+
274
+ /** Rewrite the page's relative links (assets/, llms.txt, ...) for a page `depth` folders down. */
275
+ export function rebase(html, prefix) {
276
+ if (!prefix) return html;
277
+ return html.replace(/((?:href|src)=")(?!https?:|\/|#|data:|mailto:|\.\.\/)([^"]*)(")/g, `$1${prefix}$2$3`);
278
+ }
279
+
280
+ /**
281
+ * One static search page. `chrome` renders the shared page shell:
282
+ * chrome({ head, body, noindex }) -> full HTML with the site's look, footers and scripts.
283
+ */
284
+ export function searchPageHtml(s, search, tabId, sort, { chrome }) {
285
+ const data = search.tabs[tabId];
286
+ const m = searchPageMeta(s, tabId, data, sort);
287
+ const hits = sortHits(data.results, sort, search.votes);
288
+ const ps = { ...s, url: m.url, seoTitle: m.seoTitle, description: m.description, image: m.image, imageAlt: m.imageAlt };
289
+ const depth = tabPath(tabId, sort).split('/').filter(Boolean).length;
290
+ const up = '../'.repeat(depth);
291
+ const tabs = search.live.map((t) => `<li><a href="${up}${tabPath(t.id)}"${t.id === tabId ? ' aria-current="page"' : ''}>${esc(t.label)} <small>${search.tabs[t.id].results.length}</small></a></li>`).join('');
292
+ const sorts = SORTS.map((x) => `<li><a href="${up}${tabPath(tabId, x.id)}"${x.id === sort ? ' aria-current="page"' : ''}>${esc(x.label)}</a></li>`).join('');
293
+ const tabMeta = TABS.find((x) => x.id === tabId);
294
+ const head = [
295
+ headTags(ps),
296
+ `<meta property="og:updated_time" content="${esc(data.fetchedAt)}">`,
297
+ searchJsonLd(s, tabId, data, hits, m),
298
+ ].join('\n');
299
+ const body = `<header class="waitlist-hero stack" data-space="md">
300
+ <p class="waitlist-kicker"><a href="${up || './'}">← ${esc(s.title)}</a> <span class="badge">Search</span></p>
301
+ <h1>${esc(m.h1)}</h1>
302
+ <p class="waitlist-answer">${esc(m.answer)}</p>
303
+ <form class="wl-search" role="search" method="get" action="https://pit.world/search"><label for="wl-q" class="visually-hidden">Search pit.world</label>
304
+ <div class="field-group"><input id="wl-q" name="q" type="search" value="${esc(data.query)}" required>${tabId === 'web' ? '' : `<input type="hidden" name="t" value="${esc(tabId)}">`}<button type="submit">Search</button></div></form>
305
+ </header>
306
+ <nav class="wl-tabs" aria-label="Search tabs"><ul role="list">${tabs}</ul></nav>
307
+ <nav class="wl-sorts" aria-label="Sort"><ul role="list">${sorts}</ul></nav>
308
+ <section aria-labelledby="results" class="stack"><h2 id="results" class="visually-hidden">${esc(tabMeta.label)} results</h2>
309
+ <ol role="list" class="wl-results${tabId === 'images' ? ' wl-results-images' : ''}">${hits.map((h) => hitHtml(h, tabId, search.votes.get(h.url))).join('')}</ol>
310
+ <p class="muted">Results from <a href="https://pit.world/search?q=${encodeURIComponent(data.query)}${tabId === 'web' ? '' : `&amp;t=${tabId}`}">pit.world search</a>${data.provider ? ` (${esc(data.provider)})` : ''}, updated ${esc(data.fetchedAt.slice(0, 10))}.</p>
311
+ </section>`;
312
+ return { html: rebase(chrome({ head, body, spec: ps }), up), path: tabPath(tabId, sort), meta: m };
313
+ }
314
+
315
+ /** The home page card linking every tab that has results. */
316
+ export function searchCardHtml(s, search) {
317
+ if (!search.live.length) return '';
318
+ return `<section class="card stack" aria-labelledby="browse"><h2 id="browse">Browse ${esc(s.title)}</h2>
319
+ <p class="muted">What the web is saying about ${esc(search.query)}, from pit.world search.</p>
320
+ <ul role="list" class="wl-tabs">${search.live.map((t) => `<li><a href="${tabPath(t.id)}">${esc(t.label)} <small>${search.tabs[t.id].results.length}</small></a></li>`).join('')}</ul>
321
+ </section>`;
322
+ }
323
+
324
+ /** search.json: every tab's results, for agents. */
325
+ export function searchJson(s, search) {
326
+ return JSON.stringify({
327
+ site: s.url, query: search.query, source: 'https://pit.world/api/search',
328
+ tabs: Object.fromEntries(search.live.map((t) => [t.id, { label: t.label, url: `${s.url}${tabPath(t.id)}`, fetchedAt: search.tabs[t.id].fetchedAt, results: search.tabs[t.id].results }])),
329
+ }, null, 2) + '\n';
330
+ }
331
+
332
+ /** The llms.txt section listing the search pages and their top results. */
333
+ export function searchLlms(s, search) {
334
+ if (!search?.live?.length) return '';
335
+ const lines = ['## Search', '', `Static pages of pit.world search results for "${search.query}", refreshed daily. All of them as JSON: ${s.url}search.json`, ''];
336
+ for (const t of search.live) {
337
+ const d = search.tabs[t.id];
338
+ lines.push(`### [${t.label}](${s.url}${tabPath(t.id)})`, '');
339
+ for (const r of d.results.slice(0, 5)) lines.push(`- [${r.title.replace(/[[\]]/g, '')}](${r.url})${r.summary ? `: ${clip(r.summary, 140)}` : ''}`);
340
+ lines.push('');
341
+ }
342
+ return lines.join('\n');
343
+ }
344
+
345
+ /** Web app manifest: installable, with the search tabs as shortcuts. */
346
+ export function manifestJson(s, search) {
347
+ const p = paletteFor(s.look);
348
+ return JSON.stringify({
349
+ name: s.title,
350
+ short_name: clip(s.name, 12),
351
+ description: s.description,
352
+ id: './',
353
+ start_url: './',
354
+ scope: './',
355
+ display: 'standalone',
356
+ background_color: p.bg,
357
+ theme_color: s.themeColor || p.bg,
358
+ lang: s.lang,
359
+ categories: ['news', 'social'],
360
+ icons: [
361
+ { src: 'assets/icon.svg', sizes: 'any', type: 'image/svg+xml' },
362
+ { src: 'assets/icon-192.png', sizes: '192x192', type: 'image/png' },
363
+ { src: 'assets/icon-512.png', sizes: '512x512', type: 'image/png' },
364
+ { src: 'assets/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
365
+ ],
366
+ shortcuts: (search?.live || []).slice(0, 4).map((t) => ({ name: `${t.label}: ${search.query}`, short_name: t.label, url: tabPath(t.id) })),
367
+ }, null, 2) + '\n';
368
+ }
369
+
370
+ /** OpenSearch: lets browsers add pit.world search from this site. */
371
+ export function openSearchXml(s) {
372
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"><ShortName>${esc(clip(s.title, 16))}</ShortName><Description>Search the web from ${esc(s.title)} with pit.world</Description><InputEncoding>UTF-8</InputEncoding><Image width="192" height="192" type="image/png">${esc(s.url)}assets/icon-192.png</Image><Url type="text/html" template="https://pit.world/search?q={searchTerms}"/></OpenSearchDescription>\n`;
373
+ }
374
+
375
+ /**
376
+ * Service worker: pages network-first (falling back to the cached copy, then the
377
+ * home page, so it opens offline), assets stale-while-revalidate. `ver` names the cache.
378
+ */
379
+ export function serviceWorker(ver) {
380
+ return `const C = 'wl-${ver}';
381
+ self.addEventListener('install', (e) => { e.waitUntil(caches.open(C).then((c) => c.add('./')).catch(() => {})); self.skipWaiting(); });
382
+ self.addEventListener('activate', (e) => { e.waitUntil(caches.keys().then((ks) => Promise.all(ks.filter((k) => k !== C).map((k) => caches.delete(k)))).then(() => self.clients.claim())); });
383
+ self.addEventListener('fetch', (e) => {
384
+ const r = e.request;
385
+ if (r.method !== 'GET' || new URL(r.url).origin !== location.origin) return;
386
+ if (r.mode === 'navigate') {
387
+ e.respondWith(fetch(r).then((res) => { const copy = res.clone(); caches.open(C).then((c) => c.put(r, copy)); return res; })
388
+ .catch(() => caches.match(r).then((m) => m || caches.match('./'))));
389
+ return;
390
+ }
391
+ e.respondWith(caches.open(C).then((c) => c.match(r).then((m) => {
392
+ const net = fetch(r).then((res) => { if (res.ok) c.put(r, res.clone()); return res; }).catch(() => m);
393
+ return m || net;
394
+ })));
395
+ });
396
+ `;
397
+ }
398
+
399
+ /** A full-bleed square icon for the maskable slot: the look's background, the letter in the safe zone. */
400
+ export function maskableIconSvg(s) {
401
+ const p = paletteFor(s.look);
402
+ const ch = esc((s.name.match(/[a-z0-9]/i) || ['?'])[0].toUpperCase());
403
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><rect width="512" height="512" fill="${p.bg}"/><rect x="128" y="128" width="256" height="256" rx="40" fill="none" stroke="${p.accent}" stroke-width="12"/><text x="256" y="330" text-anchor="middle" font-family="'DejaVu Sans Mono', monospace" font-size="180" font-weight="700" fill="${p.title}">${ch}</text></svg>\n`;
404
+ }
package/src/seo.js CHANGED
@@ -109,7 +109,14 @@ export function headTags(s, { noindex = false } = {}) {
109
109
  `<link rel="icon" href="assets/icon.svg" type="image/svg+xml">`,
110
110
  `<link rel="icon" href="assets/icon-192.png" type="image/png" sizes="192x192">`,
111
111
  `<link rel="apple-touch-icon" href="assets/icon-180.png">`,
112
- `<link rel="alternate" type="text/plain" href="${esc(s.url)}llms.txt" title="llms.txt">`,
112
+ `<link rel="alternate" type="text/plain" href="${esc(s.siteUrl || s.url)}llms.txt" title="llms.txt">`,
113
+ `<link rel="manifest" href="site.webmanifest">`,
114
+ `<link rel="search" type="application/opensearchdescription+xml" href="opensearch.xml" title="${esc(s.title)}">`,
115
+ `<meta name="application-name" content="${esc(s.title)}">`,
116
+ `<meta name="apple-mobile-web-app-title" content="${esc(s.title)}">`,
117
+ `<meta name="mobile-web-app-capable" content="yes">`,
118
+ `<meta name="apple-mobile-web-app-capable" content="yes">`,
119
+ `<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">`,
113
120
  `<meta property="og:type" content="website">`,
114
121
  `<meta property="og:site_name" content="${esc(s.siteName)}">`,
115
122
  `<meta property="og:locale" content="${esc(s.locale)}">`,
@@ -161,7 +168,7 @@ export function faqHtml(s, { comments = false } = {}) {
161
168
  }
162
169
 
163
170
  /** llms.txt (llmstxt.org): what it is, who it's for, status, how to join. */
164
- export function llmsTxt(s) {
171
+ export function llmsTxt(s, { extra = '' } = {}) {
165
172
  const lines = [
166
173
  `# ${s.title}`,
167
174
  '',
@@ -178,7 +185,9 @@ export function llmsTxt(s) {
178
185
  if (s.points.length) lines.push('## What is coming', '', ...s.points.map((p) => `- ${p}`), '');
179
186
  lines.push('## Questions', '');
180
187
  for (const f of s.faq) lines.push(`### ${f.q}`, '', f.a, '');
181
- lines.push('## Links', '', `- [Home](${s.url}): the waitlist page`, `- [Sitemap](${s.url}sitemap.xml)`);
188
+ if (extra) lines.push(extra);
189
+ lines.push('## Links', '', `- [Home](${s.url}): the waitlist page`, `- [Sitemap](${s.url}sitemap.xml)`, `- [Web app manifest](${s.url}site.webmanifest)`);
190
+ if (extra) lines.push(`- [Search results as JSON](${s.url}search.json)`);
182
191
  if (s.moshpit) lines.push(`- [pit.world directory](https://pit.world/directory): other Moshpit names`);
183
192
  return lines.join('\n') + '\n';
184
193
  }
@@ -194,8 +203,10 @@ export function robotsTxt(s) {
194
203
  return `# ${s.title}: crawlers and AI answer engines welcome.\n${AI_CRAWLERS.map((b) => `User-agent: ${b}`).join('\n')}\nAllow: /\n\nUser-agent: *\nAllow: /\n\nSitemap: ${s.url}sitemap.xml\n`;
195
204
  }
196
205
 
197
- export function sitemapXml(s) {
198
- return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">\n <url><loc>${esc(s.url)}</loc><lastmod>${s.updated}</lastmod><changefreq>weekly</changefreq><image:image><image:loc>${esc(s.image)}</image:loc></image:image></url>\n</urlset>\n`;
206
+ /** sitemap.xml: the home page, then `extra` pages ({ url, lastmod, image, changefreq }). */
207
+ export function sitemapXml(s, extra = []) {
208
+ const url = (u) => ` <url><loc>${esc(u.url)}</loc><lastmod>${u.lastmod}</lastmod><changefreq>${u.changefreq || 'weekly'}</changefreq>${u.image ? `<image:image><image:loc>${esc(u.image)}</image:loc></image:image>` : ''}</url>\n`;
209
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">\n${[{ url: s.url, lastmod: s.updated, image: s.image }, ...extra].map(url).join('')}</urlset>\n`;
199
210
  }
200
211
 
201
212
  /** A stable IndexNow key for a name (hex, 32 chars); override with spec.indexnowKey. */
@@ -212,7 +223,7 @@ export async function pingIndexNow(sites, { fetchImpl = globalThis.fetch, endpoi
212
223
  const res = await fetchImpl(endpoint, {
213
224
  method: 'POST',
214
225
  headers: { 'content-type': 'application/json; charset=utf-8' },
215
- body: JSON.stringify({ host, key: s.indexnowKey, keyLocation: `${s.url}${s.indexnowKey}.txt`, urlList: [s.url, `${s.url}llms.txt`] }),
226
+ body: JSON.stringify({ host, key: s.indexnowKey, keyLocation: `${s.url}${s.indexnowKey}.txt`, urlList: [s.url, `${s.url}llms.txt`, ...(s.extraUrls || [])].slice(0, 100) }),
216
227
  });
217
228
  results.push({ host, status: res.status });
218
229
  } catch (err) {
package/src/waitlist.css CHANGED
@@ -30,3 +30,19 @@
30
30
  .book-call button.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }
31
31
  .book-call[data-state="booked"] .cluster { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
32
32
  .waitlist-book, .waitlist-promo { margin-block: 2rem; }
33
+ /* search plugin: tabs, sorts and result cards, in whatever look the page wears */
34
+ .wl-tabs ul, ul.wl-tabs, .wl-sorts ul { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
35
+ .wl-tabs a, .wl-sorts a { display: inline-block; padding: .3rem .7rem; background: var(--pf-color-surface, Canvas); border: 1px solid var(--pf-color-border, currentColor); border-radius: 999px; text-decoration: none; }
36
+ .wl-tabs a[aria-current="page"], .wl-sorts a[aria-current="page"] { background: var(--pf-color-primary); color: var(--pf-color-on-primary); font-weight: 700; }
37
+ .wl-tabs small { opacity: .7; }
38
+ .wl-sorts { margin-block: .5rem 1rem; font-size: .9em; }
39
+ .wl-results { list-style: none; padding: 0; display: grid; gap: .8rem; }
40
+ .wl-hit { display: flex; gap: .9rem; align-items: flex-start; }
41
+ .wl-hit p { margin: 0; }
42
+ .wl-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex: none; }
43
+ .wl-results-images { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
44
+ .wl-hit-image { display: grid; gap: .4rem; }
45
+ .wl-hit-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
46
+ .wl-search .field-group { display: flex; gap: .4rem; }
47
+ .wl-search input[type="search"] { flex: 1; min-width: 0; }
48
+ .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }