@profullstack/waitlist 0.7.0 → 0.8.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
@@ -90,6 +90,21 @@ Both send `Access-Control-Allow-Origin: *`.
90
90
 
91
91
  MIT
92
92
 
93
+ ## Installable (PWA) and search pages (0.8)
94
+
95
+ Every site ships `site.webmanifest` (icons 192/512 + maskable, the search tabs as shortcuts),
96
+ `sw.js` (pages network-first with an offline copy, assets stale-while-revalidate; turn off
97
+ with `"pwa": false`), `opensearch.xml`, and the `search` plugin's static result pages.
98
+
99
+ Trending = (1 + net pit.world votes + a rank bonus) / (age in days + 2)^1.2; Recent = newest
100
+ first; Recommended = pit.world's own order. Search results are cached per (query, tab) in
101
+ `--cache`: daily for News/Videos/Live/Podcasts/Blogs/Social/All, weekly for the rest. The CLI
102
+ spaces searches `--search-gap-ms` apart (default 3100, under pit.world's 20/min per-IP limit),
103
+ so a first build of many sites takes about 45 s per site; later builds mostly hit the cache.
104
+
105
+ Analytics: `crawlproof` per site in `sites.json` sets that site's own CrawlProof id on every
106
+ page (home and search); without it Moshpit names report to the shared Moshpit project.
107
+
93
108
  ## A/B testing the look (0.3)
94
109
 
95
110
  Every built page runs one experiment by default, `waitlist-look-v1`: the page's own themed
@@ -112,6 +127,7 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
112
127
  | `stats` | who's waiting: a count and a signup chart |
113
128
  | `ab` | the look A/B test (see above) |
114
129
  | `faq` | visible questions and answers (the FAQPage JSON-LD stays) |
130
+ | `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
131
  | `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
132
  | `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
133
  | `share` | a Share button on the board, also behind CoinPay sign-in |
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.8.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",
package/src/build.js CHANGED
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import { mkdir, writeFile, copyFile, readFile, readdir } from 'node:fs/promises';
6
6
  import { pluginSet, keywordsFor, runPlugins, baseSlot } 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';
@@ -135,34 +139,56 @@ export function normalize(spec) {
135
139
  if (!s.plugins.has('ab')) s.ab = null;
136
140
  if (!s.keywords.length) s.keywords = keywordsFor(s);
137
141
  s.resourcesQuery = spec.resourcesQuery || '';
142
+ s.searchQuery = spec.searchQuery || '';
143
+ s.pwa = spec.pwa !== false;
138
144
  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
145
  return s;
140
146
  }
141
147
 
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>` : '';
148
+ /**
149
+ * The page shell every page shares: look, A/B script, stylesheets, marquee,
150
+ * footers, scripts and the crawlproof tag. `head` is the page's own SEO head;
151
+ * `main` the inside of <main>.
152
+ */
153
+ export function shellHtml(s, { head, main, footers = '', slot = baseSlot(s) }) {
148
154
  return `<!doctype html>
149
155
  <html lang="${esc(s.lang)}" data-theme="${esc(s.theme)}" data-look="${esc(s.look)}">
150
156
  <head>
151
157
  <meta charset="utf-8">
152
158
  <meta name="viewport" content="width=device-width, initial-scale=1">
153
159
  ${s.ab ? abHeadScript(s.ab, s.look) : ''}
154
- ${headTags(s, { noindex })}
160
+ ${head}
155
161
  <link rel="stylesheet" href="assets/profullstack.css">
156
162
  <link rel="stylesheet" href="assets/looks.css">
157
163
  <link rel="stylesheet" href="assets/charts.css">
158
164
  <link rel="stylesheet" href="assets/waitlist.css">
159
- ${jsonLdTag(s)}
160
165
  ${slot.head.join('\n')}
161
166
  </head>
162
167
  <body class="waitlist-page">
163
168
  <div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
164
169
  <main class="container">
165
- <header class="waitlist-hero stack" data-space="lg">
170
+ ${main}
171
+ <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>
172
+ </main>
173
+ <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>
174
+ ${footers}
175
+ <script src="assets/charts.global.js"></script>
176
+ <script type="module" src="assets/waitlist.js"></script>
177
+ ${slot.scripts.join('\n')}
178
+ ${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>' : ''}
179
+ ${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
180
+ </body>
181
+ </html>
182
+ `;
183
+ }
184
+
185
+ /** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
186
+ export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s) } = {}) {
187
+ const points = s.points.length
188
+ ? `<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>`
189
+ : '';
190
+ const about = s.about ? `<p>${esc(s.about)}</p>` : '';
191
+ const main = `<header class="waitlist-hero stack" data-space="lg">
166
192
  <p class="waitlist-kicker"><span class="badge">${esc(s.kicker)}</span></p>
167
193
  <h1>${esc(s.title)}</h1>
168
194
  <p class="waitlist-tagline">${esc(s.tagline)}</p>
@@ -175,18 +201,8 @@ ${slot.head.join('\n')}
175
201
  ${slot.cards.join('\n')}
176
202
  </div>
177
203
  ${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
- `;
204
+ ${slot.sections.join('\n')}`;
205
+ return shellHtml(s, { head: `${headTags(s, { noindex })}\n${jsonLdTag(s)}`, main, footers, slot });
190
206
  }
191
207
 
192
208
  /** Square icon in the look's colors (takes a normalized spec or a bare name). */
@@ -218,7 +234,7 @@ export async function renderFooters(s, { fetchImpl = globalThis.fetch } = {}) {
218
234
  * Write the site for one spec into `out`. Returns the normalized spec.
219
235
  * `images: false` skips the PNG renders (og.png, icons), e.g. where @resvg/resvg-js cannot load.
220
236
  */
221
- export async function buildSite(spec, out, { footers = true, images = true, fetchImpl, cacheDir = null, maxAgeMs } = {}) {
237
+ export async function buildSite(spec, out, { footers = true, images = true, fetchImpl, cacheDir = null, maxAgeMs, searchOpts = {} } = {}) {
222
238
  const s = normalize(spec);
223
239
  await mkdir(join(out, 'assets'), { recursive: true });
224
240
  await mkdir(join(out, '.well-known'), { recursive: true });
@@ -237,22 +253,59 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
237
253
  await writeFile(join(out, 'og.png'), await svgToPng(og));
238
254
  await writeFile(join(out, 'assets', 'icon-192.png'), await svgToPng(icon, { width: 192 }));
239
255
  await writeFile(join(out, 'assets', 'icon-180.png'), await svgToPng(icon, { width: 180 }));
256
+ await writeFile(join(out, 'assets', 'icon-512.png'), await svgToPng(icon, { width: 512 }));
257
+ await writeFile(join(out, 'assets', 'icon-maskable-512.png'), await svgToPng(maskableIconSvg(s), { width: 512 }));
240
258
  }
241
259
  const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
242
- const { slot } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs });
260
+ const { slot, search } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts });
261
+ s.searchLive = Boolean(search?.live?.length);
243
262
  // Assets are cached by browsers and gateways (max-age 1 h), so a page must name the
244
263
  // exact build of every script and stylesheet it needs, or a new page runs old code.
245
264
  const ver = await versionAssets(out);
246
265
  await writeFile(join(out, 'index.html'), withAssetVersion(pageHtml(s, { footers: foot, slot }), ver));
247
266
  await writeFile(join(out, '404.html'), withAssetVersion(pageHtml(s, { footers: foot, noindex: true, slot }), ver));
267
+ const pages = s.searchLive ? await writeSearch(s, search, out, { footers: foot, slot, ver, images }) : [];
268
+ s.extraUrls = pages.map((p) => p.url);
269
+ await writeFile(join(out, 'site.webmanifest'), manifestJson(s, s.searchLive ? search : null));
270
+ await writeFile(join(out, 'opensearch.xml'), openSearchXml(s));
271
+ if (s.pwa) await writeFile(join(out, 'sw.js'), serviceWorker(ver));
248
272
  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));
273
+ await writeFile(join(out, 'sitemap.xml'), sitemapXml(s, pages));
274
+ await writeFile(join(out, 'llms.txt'), llmsTxt(s, { extra: s.searchLive ? searchLlms(s, search) : '' }));
251
275
  await writeFile(join(out, `${s.indexnowKey}.txt`), `${s.indexnowKey}\n`);
252
276
  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
277
  return s;
254
278
  }
255
279
 
280
+ /**
281
+ * Write the static search pages: one per tab that has results, times each sort,
282
+ * plus an Open Graph card per tab and search.json. Returns the sitemap entries
283
+ * (the recommended view of each tab; the sorted views point their canonical at it).
284
+ */
285
+ async function writeSearch(s, search, out, { footers, slot, ver, images }) {
286
+ const pages = [];
287
+ // The waitlist form rides along on every search page; the home page's own sections do not.
288
+ const pageSlot = { ...slot, cards: [], sections: [] };
289
+ for (const t of search.live) {
290
+ const data = search.tabs[t.id];
291
+ for (const sort of SORTS) {
292
+ const { html, path } = searchPageHtml(s, search, t.id, sort.id, {
293
+ 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),
294
+ });
295
+ await mkdir(join(out, path), { recursive: true });
296
+ await writeFile(join(out, path, 'index.html'), html);
297
+ }
298
+ const m = searchPageMeta(s, t.id, data);
299
+ if (images) {
300
+ const card = ogSvg({ ...s, kicker: `Search · ${t.label}`, title: s.title, tagline: `${t.label}: ${data.query}`, button: 'Browse the results' });
301
+ await writeFile(join(out, tabPath(t.id), 'og.png'), await svgToPng(card));
302
+ }
303
+ pages.push({ url: m.url, lastmod: data.fetchedAt.slice(0, 10), image: m.image, changefreq: 'daily' });
304
+ }
305
+ await writeFile(join(out, 'search.json'), searchJson(s, search));
306
+ return pages;
307
+ }
308
+
256
309
  /** A short hash of everything in assets/; module imports between assets carry it too. */
257
310
  export async function versionAssets(out) {
258
311
  const dir = join(out, 'assets');
@@ -271,7 +324,7 @@ export async function versionAssets(out) {
271
324
 
272
325
  /** assets/x.css -> assets/x.css?v=<ver> in href/src attributes. */
273
326
  export function withAssetVersion(html, ver) {
274
- return html.replace(/((?:href|src)=")(assets\/[^"?#]+)(")/g, `$1$2?v=${ver}$3`);
327
+ return html.replace(/((?:href|src)=")((?:\.\.\/)*assets\/[^"?#]+)(")/g, `$1$2?v=${ver}$3`);
275
328
  }
276
329
 
277
330
  /** Build many: specs is an array; each lands in `${outRoot}/${name}`. */
package/src/plugins.js CHANGED
@@ -18,10 +18,11 @@ import { createRequire } from 'node:module';
18
18
  import { createHash } from 'node:crypto';
19
19
  import { dirname, join } from 'node:path';
20
20
  import { esc } from './seo.js';
21
+ import { fetchSearch, searchCardHtml } from './search.js';
21
22
 
22
23
  const require = createRequire(import.meta.url);
23
24
 
24
- export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo'];
25
+ export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo'];
25
26
 
26
27
  /** Resolve a site's `plugins` setting to a Set (default: all of them). */
27
28
  export function pluginSet(setting) {
@@ -114,12 +115,21 @@ export function baseSlot(s) {
114
115
  }
115
116
 
116
117
  /** 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 } = {}) {
118
+ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts = {} } = {}) {
118
119
  const on = s.plugins;
119
120
  const slot = baseSlot(s);
120
121
  let res = null;
122
+ let search = null;
123
+ if (on.has('search')) {
124
+ search = await fetchSearch(s, { ...(fetchImpl ? { fetchImpl } : {}), cacheDir, ...(maxAgeMs ? { maxAgeMs } : {}), ...searchOpts });
125
+ slot.cards.push(searchCardHtml(s, search));
126
+ }
121
127
  if (on.has('resources')) {
122
- res = await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
128
+ const web = search?.tabs?.web;
129
+ // The All tab already searched the same words: reuse it instead of searching again.
130
+ res = web?.results?.length && !s.resourcesQuery
131
+ ? { 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 })) }
132
+ : await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
123
133
  slot.sections.push(resourcesHtml(s, res, { comments: on.has('board'), share: on.has('share') }));
124
134
  if (res.results.length) await writeFile(join(out, 'resources.json'), JSON.stringify(res, null, 2) + '\n');
125
135
  }
@@ -158,7 +168,7 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {})
158
168
  await writeFile(join(out, 'feed.json'), f.json);
159
169
  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
170
  }
161
- return { slot, resources: res };
171
+ return { slot, resources: res, search };
162
172
  }
163
173
 
164
174
  // --- 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; }