@profullstack/waitlist 0.6.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
@@ -101,7 +116,7 @@ The page reports one exposure a day; a signup is the conversion. Both go through
101
116
  waitlist API, which holds the CrawlProof token. Stop the experiment with a winner in
102
117
  CrawlProof and every page switches to it. Turn it off per site with `"ab": false`.
103
118
 
104
- ## Plugins (0.4)
119
+ ## Plugins (0.4; buyaday 0.6; book + promo 0.7)
105
120
 
106
121
  Every page showcases all plugins by default. Pick per site in `sites.json`:
107
122
  `"plugins": ["form", "board"]` keeps only those, `"plugins": { "faq": false }` drops some.
@@ -112,11 +127,14 @@ 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 |
118
134
  | `feed` | `feed.xml` (RSS) and `feed.json` (JSON Feed) of the page and its resources, for syndication |
119
135
  | `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) |
136
+ | `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 |
137
+ | `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 |
120
138
 
121
139
  `keywords` (also the `<meta name="keywords">`) default to the name's labels plus the tagline's
122
140
  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.6.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",
@@ -27,7 +27,8 @@
27
27
  "./build": "./src/build.js",
28
28
  "./seo": "./src/seo.js",
29
29
  "./waitlist.css": "./src/waitlist.css",
30
- "./package.json": "./package.json"
30
+ "./package.json": "./package.json",
31
+ "./book": "./src/book.js"
31
32
  },
32
33
  "bin": {
33
34
  "waitlist": "bin/waitlist.js"
@@ -50,7 +51,8 @@
50
51
  "@profullstack/footer": "^0.7.3",
51
52
  "@resvg/resvg-js": "^2.6.2",
52
53
  "@profullstack/comments": "^0.2.0",
53
- "@profullstack/marketing-widgets": "^0.1.0"
54
+ "@profullstack/marketing-widgets": "^0.1.0",
55
+ "@profullstack/cross-promo": "^0.2.1"
54
56
  },
55
57
  "devDependencies": {
56
58
  "@profullstack/abtest": "^0.1.0"
package/src/book.js ADDED
@@ -0,0 +1,224 @@
1
+ /**
2
+ * <book-a-call>: our booking widget for any static page.
3
+ *
4
+ * <book-a-call handle="chovy"><a href="https://outreachgraph.com/calendar/chovy">Book a call</a></book-a-call>
5
+ * <script type="module" src="assets/book.js"></script>
6
+ *
7
+ * It is the guest side of an OutreachGraph booking page (outreachgraph.com/calendar/<handle>):
8
+ * pick a time in your own time zone, give a name and an email, get a PairUX video call. The
9
+ * booking lands in the host's OutreachGraph CRM. Whatever is inside the element is the
10
+ * no-script fallback, and it comes back if the calendar cannot be reached.
11
+ *
12
+ * Talks to OutreachGraph's keyless public API (CORS open):
13
+ * GET {api}/api/v1/public/calendar/{handle} -> {page}
14
+ * GET {api}/api/v1/public/calendar/{handle}/slots?from=&days= -> {slots:[{start,end}]}
15
+ * POST {api}/api/v1/public/calendar/{handle}/book {start,name,email,note,timezone} -> {booking}
16
+ */
17
+
18
+ export const DEFAULT_BOOKING_API = 'https://outreachgraph.com';
19
+ export const DEFAULT_HANDLE = 'chovy';
20
+ const DAY_MS = 86_400_000;
21
+ const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
22
+
23
+ /** "YYYY-MM-DD" for an instant as seen in a zone. */
24
+ export function ymd(ms, zone) {
25
+ return new Intl.DateTimeFormat('en-CA', { timeZone: zone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date(ms));
26
+ }
27
+
28
+ export function addDays(date, days) {
29
+ const [y, m, d] = date.split('-').map(Number);
30
+ return new Date(Date.UTC(y, m - 1, d + days)).toISOString().slice(0, 10);
31
+ }
32
+
33
+ /** Slots grouped by the date the guest sees, in order: [[ 'YYYY-MM-DD', [slot...] ], ...]. */
34
+ export function groupByDay(slots, zone) {
35
+ const days = new Map();
36
+ for (const slot of slots) {
37
+ const key = ymd(Date.parse(slot.start), zone);
38
+ if (!days.has(key)) days.set(key, []);
39
+ days.get(key).push(slot);
40
+ }
41
+ return [...days.entries()].sort(([a], [b]) => (a < b ? -1 : 1));
42
+ }
43
+
44
+ export function guestZone() {
45
+ try {
46
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
47
+ } catch {
48
+ return 'UTC';
49
+ }
50
+ }
51
+
52
+ const fmt = (opts, zone) => new Intl.DateTimeFormat(undefined, { timeZone: zone, ...opts });
53
+
54
+ /** Small client for the public calendar API. */
55
+ export function bookingClient({ api = DEFAULT_BOOKING_API, handle = DEFAULT_HANDLE, fetchImpl = globalThis.fetch } = {}) {
56
+ const base = `${api.replace(/\/$/, '')}/api/v1/public/calendar/${encodeURIComponent(handle)}`;
57
+ const json = async (res) => ({ res, body: await res.json().catch(() => ({})) });
58
+ return {
59
+ async page() {
60
+ const { res, body } = await json(await fetchImpl(base, { headers: { accept: 'application/json' } }));
61
+ if (!res.ok || !body.page) throw new Error('booking page not found');
62
+ return body.page;
63
+ },
64
+ async slots(from, days = 7) {
65
+ const { res, body } = await json(await fetchImpl(`${base}/slots?from=${from}&days=${days}`, { headers: { accept: 'application/json' } }));
66
+ if (!res.ok) throw new Error('could not load times');
67
+ return Array.isArray(body.slots) ? body.slots : [];
68
+ },
69
+ async book({ start, name, email, note = '', timezone = guestZone() }) {
70
+ const { res, body } = await json(
71
+ await fetchImpl(`${base}/book`, {
72
+ method: 'POST',
73
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
74
+ body: JSON.stringify({ start, name, email, note, timezone }),
75
+ }),
76
+ );
77
+ if (!res.ok || !body.booking) {
78
+ const err = new Error(body.error?.message ?? body.message ?? 'That did not work. Try another time.');
79
+ err.status = res.status;
80
+ throw err;
81
+ }
82
+ return body.booking;
83
+ },
84
+ };
85
+ }
86
+
87
+ const HTMLElementBase = globalThis.HTMLElement ?? class {};
88
+
89
+ function el(tag, attrs = {}, ...children) {
90
+ const node = document.createElement(tag);
91
+ for (const [k, v] of Object.entries(attrs)) {
92
+ if (v === undefined || v === null || v === false) continue;
93
+ if (k === 'text') node.textContent = v;
94
+ else if (k.startsWith('on')) node.addEventListener(k.slice(2), v);
95
+ else node.setAttribute(k, v === true ? '' : String(v));
96
+ }
97
+ for (const c of children.flat()) if (c != null && c !== false) node.append(c);
98
+ return node;
99
+ }
100
+
101
+ /** <book-a-call [handle] [api] [heading]>: light DOM, styled by @profullstack/css. */
102
+ export class BookACall extends HTMLElementBase {
103
+ connectedCallback() {
104
+ if (this.dataset.ready) return;
105
+ this.dataset.ready = '1';
106
+ this.fallback = [...this.childNodes];
107
+ this.zone = guestZone();
108
+ this.client = bookingClient({ api: this.getAttribute('api') || DEFAULT_BOOKING_API, handle: this.getAttribute('handle') || DEFAULT_HANDLE });
109
+ this.state = { page: null, from: null, days: null, day: null, chosen: null, booked: null, error: null, busy: false };
110
+ this.start();
111
+ }
112
+
113
+ async start() {
114
+ try {
115
+ const page = await this.client.page();
116
+ this.state.page = page;
117
+ this.today = ymd(Date.now(), page.timezone);
118
+ this.lastDay = ymd(Date.now() + page.maxDaysAhead * DAY_MS, page.timezone);
119
+ await this.load(this.today);
120
+ } catch {
121
+ this.replaceChildren(...this.fallback); // the plain link still works
122
+ }
123
+ }
124
+
125
+ async load(from) {
126
+ this.state.from = from;
127
+ this.state.days = null;
128
+ this.state.chosen = null;
129
+ this.render();
130
+ try {
131
+ // One day either side, so slots near midnight regroup into the guest's own day.
132
+ const slots = await this.client.slots(addDays(from, -1), 9);
133
+ const now = Date.now();
134
+ this.state.days = groupByDay(slots.filter((s) => Date.parse(s.start) > now), this.zone);
135
+ this.state.day = this.state.days[0]?.[0] ?? null;
136
+ } catch {
137
+ this.state.days = [];
138
+ this.state.error = 'Could not load times. Try again in a moment.';
139
+ }
140
+ this.render();
141
+ }
142
+
143
+ async submit(form) {
144
+ const data = new FormData(form);
145
+ const name = String(data.get('name') ?? '').trim();
146
+ const email = String(data.get('email') ?? '').trim();
147
+ if (!name || !EMAIL_RE.test(email)) {
148
+ this.state.error = 'Enter your name and a valid email.';
149
+ return this.render();
150
+ }
151
+ this.state.busy = true;
152
+ this.state.error = null;
153
+ this.render();
154
+ try {
155
+ this.state.booked = await this.client.book({ start: this.state.chosen.start, name, email, note: String(data.get('note') ?? ''), timezone: this.zone });
156
+ this.state.email = email;
157
+ } catch (err) {
158
+ this.state.error = err.message;
159
+ if (err.status === 409) return this.load(this.state.from);
160
+ } finally {
161
+ this.state.busy = false;
162
+ }
163
+ this.render();
164
+ }
165
+
166
+ render() {
167
+ const { page, days, day, chosen, booked, error, busy } = this.state;
168
+ const zone = this.zone;
169
+ const long = (iso) => fmt({ weekday: 'long', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit', timeZoneName: 'short' }, zone).format(new Date(iso));
170
+ const head = el('div', { class: 'book-head' },
171
+ el('strong', { text: `${page.title} with ${page.hostName || page.handle}` }),
172
+ el('small', { class: 'muted', text: `${page.durationMinutes} minutes · PairUX video call · times in ${zone}` }));
173
+
174
+ if (booked) {
175
+ return this.replaceChildren(el('div', { class: 'book-call stack', 'data-state': 'booked' },
176
+ el('p', { class: 'badge', text: 'Booked' }),
177
+ el('h3', { text: long(booked.startsAt) }),
178
+ el('p', { text: `${page.title} with ${page.hostName || page.handle}. A confirmation is on its way to ${this.state.email}.` }),
179
+ el('div', { class: 'cluster' },
180
+ el('a', { class: 'button', href: booked.meetingUrl, rel: 'noopener', text: 'Call link' }),
181
+ el('a', { href: booked.icsUrl, rel: 'noopener', text: 'Add to calendar' }),
182
+ el('a', { href: booked.manageUrl, rel: 'noopener', text: 'Reschedule or cancel' }))));
183
+ }
184
+
185
+ const status = error ? el('p', { class: 'alert', role: 'status', 'data-tone': 'error', text: error }) : null;
186
+
187
+ if (chosen) {
188
+ const form = el('form', { class: 'stack', novalidate: true, onsubmit: (e) => { e.preventDefault(); this.submit(form); } },
189
+ el('p', {}, el('strong', { text: long(chosen.start) }), ' ', el('button', { type: 'button', class: 'link', onclick: () => { this.state.chosen = null; this.state.error = null; this.render(); }, text: 'change' })),
190
+ el('label', { for: 'bk-name', text: 'Your name' }), el('input', { id: 'bk-name', name: 'name', autocomplete: 'name', required: true }),
191
+ el('label', { for: 'bk-email', text: 'Email' }), el('input', { id: 'bk-email', name: 'email', type: 'email', autocomplete: 'email', required: true }),
192
+ el('label', { for: 'bk-note', text: 'What do you want to talk about? (optional)' }), el('textarea', { id: 'bk-note', name: 'note', rows: 3, maxlength: 1000 }),
193
+ status,
194
+ el('button', { type: 'submit', disabled: busy, text: busy ? 'Booking…' : 'Book this time' }));
195
+ return this.replaceChildren(el('div', { class: 'book-call stack' }, head, form));
196
+ }
197
+
198
+ const canBack = this.state.from > this.today;
199
+ const canNext = addDays(this.state.from, 7) <= this.lastDay;
200
+ const nav = el('div', { class: 'cluster book-nav' },
201
+ el('button', { type: 'button', 'data-variant': 'ghost', disabled: !canBack, onclick: () => this.load(addDays(this.state.from, -7)), text: '← Earlier' }),
202
+ el('button', { type: 'button', 'data-variant': 'ghost', disabled: !canNext, onclick: () => this.load(addDays(this.state.from, 7)), text: 'Later →' }));
203
+
204
+ let body;
205
+ if (days === null) body = el('p', { class: 'muted', role: 'status', text: 'Loading open times…' });
206
+ else if (!days.length) body = el('p', { class: 'muted', text: 'No open times this week. Try later.' });
207
+ else {
208
+ const dayLabel = (key) => fmt({ weekday: 'short', month: 'short', day: 'numeric' }, 'UTC').format(new Date(`${key}T12:00:00Z`));
209
+ const current = days.find(([k]) => k === day) ?? days[0];
210
+ body = el('div', { class: 'stack', 'data-space': 'sm' },
211
+ el('div', { class: 'cluster book-days', role: 'group', 'aria-label': 'Day' },
212
+ days.map(([key]) => el('button', { type: 'button', 'data-variant': key === current[0] ? null : 'secondary', 'aria-pressed': String(key === current[0]), onclick: () => { this.state.day = key; this.render(); }, text: dayLabel(key) }))),
213
+ el('div', { class: 'cluster book-times', role: 'group', 'aria-label': 'Time' },
214
+ current[1].map((slot) => el('button', { type: 'button', 'data-variant': 'secondary', onclick: () => { this.state.chosen = slot; this.state.error = null; this.render(); }, text: fmt({ hour: 'numeric', minute: '2-digit' }, zone).format(new Date(slot.start)) }))));
215
+ }
216
+ this.replaceChildren(el('div', { class: 'book-call stack' }, head, body, status, nav));
217
+ }
218
+ }
219
+
220
+ export function defineBooking() {
221
+ if (globalThis.customElements && !customElements.get('book-a-call')) customElements.define('book-a-call', BookACall);
222
+ }
223
+
224
+ defineBooking();
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';
@@ -122,6 +126,8 @@ export function normalize(spec) {
122
126
  publisher: spec.publisher === undefined ? { name: 'Profullstack', url: 'https://profullstack.com' } : spec.publisher,
123
127
  schema: spec.schema || null,
124
128
  audience: spec.audience || '',
129
+ promoAudience: spec.promoAudience || null,
130
+ booking: spec.booking && typeof spec.booking === 'object' ? spec.booking : null,
125
131
  indexnowKey: spec.indexnowKey || indexNowKey(name),
126
132
  updated: spec.updated || new Date().toISOString().slice(0, 10),
127
133
  };
@@ -133,34 +139,56 @@ export function normalize(spec) {
133
139
  if (!s.plugins.has('ab')) s.ab = null;
134
140
  if (!s.keywords.length) s.keywords = keywordsFor(s);
135
141
  s.resourcesQuery = spec.resourcesQuery || '';
142
+ s.searchQuery = spec.searchQuery || '';
143
+ s.pwa = spec.pwa !== false;
136
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;
137
145
  return s;
138
146
  }
139
147
 
140
- /** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
141
- export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s) } = {}) {
142
- const points = s.points.length
143
- ? `<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>`
144
- : '';
145
- 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) }) {
146
154
  return `<!doctype html>
147
155
  <html lang="${esc(s.lang)}" data-theme="${esc(s.theme)}" data-look="${esc(s.look)}">
148
156
  <head>
149
157
  <meta charset="utf-8">
150
158
  <meta name="viewport" content="width=device-width, initial-scale=1">
151
159
  ${s.ab ? abHeadScript(s.ab, s.look) : ''}
152
- ${headTags(s, { noindex })}
160
+ ${head}
153
161
  <link rel="stylesheet" href="assets/profullstack.css">
154
162
  <link rel="stylesheet" href="assets/looks.css">
155
163
  <link rel="stylesheet" href="assets/charts.css">
156
164
  <link rel="stylesheet" href="assets/waitlist.css">
157
- ${jsonLdTag(s)}
158
165
  ${slot.head.join('\n')}
159
166
  </head>
160
167
  <body class="waitlist-page">
161
168
  <div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
162
169
  <main class="container">
163
- <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">
164
192
  <p class="waitlist-kicker"><span class="badge">${esc(s.kicker)}</span></p>
165
193
  <h1>${esc(s.title)}</h1>
166
194
  <p class="waitlist-tagline">${esc(s.tagline)}</p>
@@ -173,18 +201,8 @@ ${slot.head.join('\n')}
173
201
  ${slot.cards.join('\n')}
174
202
  </div>
175
203
  ${s.plugins.has('faq') ? faqHtml(s, { comments: s.plugins.has('board') }) : ''}
176
- ${slot.sections.join('\n')}
177
- <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>
178
- </main>
179
- <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>
180
- ${footers}
181
- <script src="assets/charts.global.js"></script>
182
- <script type="module" src="assets/waitlist.js"></script>
183
- ${slot.scripts.join('\n')}
184
- ${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
185
- </body>
186
- </html>
187
- `;
204
+ ${slot.sections.join('\n')}`;
205
+ return shellHtml(s, { head: `${headTags(s, { noindex })}\n${jsonLdTag(s)}`, main, footers, slot });
188
206
  }
189
207
 
190
208
  /** Square icon in the look's colors (takes a normalized spec or a bare name). */
@@ -216,7 +234,7 @@ export async function renderFooters(s, { fetchImpl = globalThis.fetch } = {}) {
216
234
  * Write the site for one spec into `out`. Returns the normalized spec.
217
235
  * `images: false` skips the PNG renders (og.png, icons), e.g. where @resvg/resvg-js cannot load.
218
236
  */
219
- 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 = {} } = {}) {
220
238
  const s = normalize(spec);
221
239
  await mkdir(join(out, 'assets'), { recursive: true });
222
240
  await mkdir(join(out, '.well-known'), { recursive: true });
@@ -235,22 +253,59 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
235
253
  await writeFile(join(out, 'og.png'), await svgToPng(og));
236
254
  await writeFile(join(out, 'assets', 'icon-192.png'), await svgToPng(icon, { width: 192 }));
237
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 }));
238
258
  }
239
259
  const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
240
- 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);
241
262
  // Assets are cached by browsers and gateways (max-age 1 h), so a page must name the
242
263
  // exact build of every script and stylesheet it needs, or a new page runs old code.
243
264
  const ver = await versionAssets(out);
244
265
  await writeFile(join(out, 'index.html'), withAssetVersion(pageHtml(s, { footers: foot, slot }), ver));
245
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));
246
272
  await writeFile(join(out, 'robots.txt'), robotsTxt(s));
247
- await writeFile(join(out, 'sitemap.xml'), sitemapXml(s));
248
- 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) : '' }));
249
275
  await writeFile(join(out, `${s.indexnowKey}.txt`), `${s.indexnowKey}\n`);
250
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');
251
277
  return s;
252
278
  }
253
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
+
254
309
  /** A short hash of everything in assets/; module imports between assets carry it too. */
255
310
  export async function versionAssets(out) {
256
311
  const dir = join(out, 'assets');
@@ -269,7 +324,7 @@ export async function versionAssets(out) {
269
324
 
270
325
  /** assets/x.css -> assets/x.css?v=<ver> in href/src attributes. */
271
326
  export function withAssetVersion(html, ver) {
272
- 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`);
273
328
  }
274
329
 
275
330
  /** Build many: specs is an array; each lands in `${outRoot}/${name}`. */
package/src/plugins.js CHANGED
@@ -7,16 +7,22 @@
7
7
  *
8
8
  * A plugin adds HTML to named slots of the page and may write files:
9
9
  * head, hero, cards, sections, scripts.
10
+ *
11
+ * book the Profullstack pitch and our booking widget (<book-a-call>, OutreachGraph
12
+ * calendar, PairUX call). `"booking": {"handle": "chovy"}` picks the calendar.
13
+ * promo "More from the network": sister properties from @profullstack/cross-promo.
14
+ * `"promoAudience": "developers"` (or a list) picks who the reader is.
10
15
  */
11
16
  import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises';
12
17
  import { createRequire } from 'node:module';
13
18
  import { createHash } from 'node:crypto';
14
19
  import { dirname, join } from 'node:path';
15
20
  import { esc } from './seo.js';
21
+ import { fetchSearch, searchCardHtml } from './search.js';
16
22
 
17
23
  const require = createRequire(import.meta.url);
18
24
 
19
- export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'resources', 'board', 'share', 'feed', 'buyaday'];
25
+ export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'search', 'resources', 'board', 'share', 'feed', 'buyaday', 'book', 'promo'];
20
26
 
21
27
  /** Resolve a site's `plugins` setting to a Set (default: all of them). */
22
28
  export function pluginSet(setting) {
@@ -109,12 +115,21 @@ export function baseSlot(s) {
109
115
  }
110
116
 
111
117
  /** Everything the plugins add to one page: { head, hero, cards, sections, scripts } and files to write. */
112
- export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {}) {
118
+ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, searchOpts = {} } = {}) {
113
119
  const on = s.plugins;
114
120
  const slot = baseSlot(s);
115
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
+ }
116
127
  if (on.has('resources')) {
117
- 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 });
118
133
  slot.sections.push(resourcesHtml(s, res, { comments: on.has('board'), share: on.has('share') }));
119
134
  if (res.results.length) await writeFile(join(out, 'resources.json'), JSON.stringify(res, null, 2) + '\n');
120
135
  }
@@ -141,11 +156,89 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs } = {})
141
156
  slot.scripts.push('<script type="module" src="assets/mw-widgets.js"></script>');
142
157
  }
143
158
  }
159
+ if (on.has('book')) {
160
+ await copyFile(join(dirname(new URL(import.meta.url).pathname), 'book.js'), join(out, 'assets', 'book.js'));
161
+ slot.sections.push(bookHtml(s));
162
+ slot.scripts.push('<script type="module" src="assets/book.js"></script>');
163
+ }
164
+ if (on.has('promo')) slot.sections.push(promoHtml(await fetchPromo(s)));
144
165
  if (on.has('feed')) {
145
166
  const f = feeds(s, res);
146
167
  await writeFile(join(out, 'feed.xml'), f.rss);
147
168
  await writeFile(join(out, 'feed.json'), f.json);
148
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">`);
149
170
  }
150
- return { slot, resources: res };
171
+ return { slot, resources: res, search };
172
+ }
173
+
174
+ // --- book: the Profullstack pitch + our booking widget ------------------------
175
+
176
+ /** What Profullstack sells, in four lines. Short and true; the source is profullstack.com. */
177
+ export const PITCH = {
178
+ heading: 'Need something built? Talk to the people who built this.',
179
+ lead: 'Profullstack is an agentic engineering firm: senior engineers run fleets of AI coding agents on your codebase, and every change ships through review, tests and CI.',
180
+ lines: [
181
+ { title: 'Rent hardware', text: 'CPU, GPU and storage without a sales call or a long contract.', href: 'https://r4ck.dev' },
182
+ { title: 'Cyber security', text: 'Catch attacks on your servers, with fixes shipped as pull requests.', href: 'https://threatcrush.com' },
183
+ { title: 'Sales', text: 'Turn the people already engaging with you into a pipeline.', href: 'https://outreachgraph.com' },
184
+ { title: 'Automation', text: 'Hand repeatable work to agents that check their own results.', href: 'https://profullstack.com' },
185
+ ],
186
+ };
187
+
188
+ export function bookingFor(s) {
189
+ const b = s.booking && typeof s.booking === 'object' ? s.booking : {};
190
+ const handle = String(b.handle || 'chovy');
191
+ const api = String(b.api || 'https://outreachgraph.com').replace(/\/$/, '');
192
+ return { handle, api, url: `${api}/calendar/${encodeURIComponent(handle)}` };
193
+ }
194
+
195
+ const utm = (href, s, campaign) => {
196
+ try {
197
+ const u = new URL(href);
198
+ u.searchParams.set('utm_source', s.host || s.name);
199
+ u.searchParams.set('utm_medium', 'waitlist');
200
+ u.searchParams.set('utm_campaign', campaign);
201
+ return u.toString();
202
+ } catch {
203
+ return href;
204
+ }
205
+ };
206
+
207
+ export function bookHtml(s) {
208
+ const b = bookingFor(s);
209
+ return `<section class="card stack waitlist-book" aria-labelledby="book"><h2 id="book">${esc(PITCH.heading)}</h2>
210
+ <p>${esc(PITCH.lead)}</p>
211
+ <ul role="list" class="grid waitlist-pitch" data-columns="2">${PITCH.lines.map((l) => `<li><a href="${esc(utm(l.href, s, 'pitch'))}" rel="noopener"><strong>${esc(l.title)}</strong></a><br><small class="muted">${esc(l.text)}</small></li>`).join('')}</ul>
212
+ <h3>Book a free 30-minute call</h3>
213
+ <book-a-call handle="${esc(b.handle)}" api="${esc(b.api)}"><p><a class="button" href="${esc(b.url)}" rel="noopener">Pick a time for a call</a></p></book-a-call>
214
+ </section>`;
215
+ }
216
+
217
+ // --- promo: more from the network ------------------------------------------------
218
+
219
+ /** Who reads this site, for the cross-promo catalog: the spec's own, else by hierarchy. */
220
+ export function audienceFor(s) {
221
+ if (s.promoAudience) return [].concat(s.promoAudience);
222
+ const top = String(s.name).split('.')[0];
223
+ if (top === 'comp' || top === 'sci') return ['developers', 'makers'];
224
+ if (top === 'news' || top === 'talk') return ['publishers', 'makers'];
225
+ return ['makers', 'publishers'];
226
+ }
227
+
228
+ export async function fetchPromo(s, { limit = 6 } = {}) {
229
+ try {
230
+ const { promoBlock } = await import('@profullstack/cross-promo');
231
+ const block = await promoBlock({ site: s.host, audience: audienceFor(s), limit, utm: false });
232
+ return block.items.map((i) => ({ ...i, href: utm(i.href, s, 'cross-promo') }));
233
+ } catch (err) {
234
+ process.emitWarning(`cross-promo skipped for ${s.host}: ${err.message}`);
235
+ return [];
236
+ }
237
+ }
238
+
239
+ export function promoHtml(items) {
240
+ if (!items?.length) return '';
241
+ return `<section class="stack waitlist-promo" aria-labelledby="network"><h2 id="network">More from the network</h2>
242
+ <ul role="list" class="grid" data-columns="3">${items.map((i) => `<li class="card stack" data-space="sm"><a href="${esc(i.href)}" rel="noopener"><strong>${esc(i.name)}</strong></a><p>${esc(i.pitch)}</p></li>`).join('')}</ul>
243
+ </section>`;
151
244
  }
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
@@ -19,3 +19,30 @@
19
19
  /* Looks (neon, matrix, terminal, amber, synthwave, geocities, vaporwave) come from
20
20
  @profullstack/css/looks: <html data-look="...">. Only page tweaks live here. */
21
21
  [data-look] .waitlist-hero h1 { font-size: clamp(2.2rem, 7vw, 4.5rem); }
22
+
23
+ /* book: the Profullstack pitch and <book-a-call> (0.6.0) */
24
+ .waitlist-book .waitlist-pitch li { padding-block: 0.25rem; }
25
+ .book-call { border: 1px solid var(--border, currentColor); border-radius: var(--radius, 0.5rem); padding: 1rem; }
26
+ .book-head { display: flex; flex-direction: column; gap: 0.125rem; }
27
+ .book-days, .book-times { display: flex; flex-wrap: wrap; gap: 0.375rem; }
28
+ .book-days button, .book-times button { min-width: 5.5rem; }
29
+ .book-nav { display: flex; justify-content: space-between; gap: 0.5rem; }
30
+ .book-call button.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }
31
+ .book-call[data-state="booked"] .cluster { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
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; }