@profullstack/waitlist 0.3.0 → 0.5.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 +19 -0
- package/bin/waitlist.js +3 -1
- package/package.json +3 -2
- package/src/build.js +16 -12
- package/src/plugins.js +136 -0
- package/src/seo.js +3 -2
package/README.md
CHANGED
|
@@ -100,3 +100,22 @@ page and [CrawlProof](https://crawlproof.com/dashboard/experiments/waitlist-look
|
|
|
100
100
|
The page reports one exposure a day; a signup is the conversion. Both go through the
|
|
101
101
|
waitlist API, which holds the CrawlProof token. Stop the experiment with a winner in
|
|
102
102
|
CrawlProof and every page switches to it. Turn it off per site with `"ab": false`.
|
|
103
|
+
|
|
104
|
+
## Plugins (0.4)
|
|
105
|
+
|
|
106
|
+
Every page showcases all plugins by default. Pick per site in `sites.json`:
|
|
107
|
+
`"plugins": ["form", "board"]` keeps only those, `"plugins": { "faq": false }` drops some.
|
|
108
|
+
|
|
109
|
+
| plugin | adds |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `form` | the waitlist signup |
|
|
112
|
+
| `stats` | who's waiting: a count and a signup chart |
|
|
113
|
+
| `ab` | the look A/B test (see above) |
|
|
114
|
+
| `faq` | visible questions and answers (the FAQPage JSON-LD stays) |
|
|
115
|
+
| `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
|
+
| `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
|
+
| `share` | a Share button on the board, also behind CoinPay sign-in |
|
|
118
|
+
| `feed` | `feed.xml` (RSS) and `feed.json` (JSON Feed) of the page and its resources, for syndication |
|
|
119
|
+
|
|
120
|
+
`keywords` (also the `<meta name="keywords">`) default to the name's labels plus the tagline's
|
|
121
|
+
meaningful words; set `keywords` or `resourcesQuery` per site to steer the resources.
|
package/bin/waitlist.js
CHANGED
|
@@ -17,6 +17,8 @@ flags:
|
|
|
17
17
|
--description <t> meta description (default: derived from tagline + points)
|
|
18
18
|
--theme dark|light
|
|
19
19
|
--look <look> neon|matrix|terminal|amber|synthwave|geocities|vaporwave (default: picked from the name)
|
|
20
|
+
--cache <dir> where pit.world search results are cached (default .waitlist-cache)
|
|
21
|
+
--max-age-hours <n> refresh cached search results older than this (default 20)
|
|
20
22
|
--no-footers skip the webring + pit.world footers (offline builds)
|
|
21
23
|
--no-images skip the PNG renders (og.png, icons)
|
|
22
24
|
|
|
@@ -42,7 +44,7 @@ for (let i = 0; i < argv.length; i++) {
|
|
|
42
44
|
} else pos.push(a);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
const opts = { footers: flags.footers !== false, images: flags.images !== false };
|
|
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 };
|
|
46
48
|
const pick = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
47
49
|
if (cmd === 'build') {
|
|
48
50
|
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.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"@profullstack/charts": "^0.3.0",
|
|
49
49
|
"@profullstack/css": "^0.6.0",
|
|
50
50
|
"@profullstack/footer": "^0.7.3",
|
|
51
|
-
"@resvg/resvg-js": "^2.6.2"
|
|
51
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
52
|
+
"@profullstack/comments": "^0.2.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@profullstack/abtest": "^0.1.0"
|
package/src/build.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* for one name, ready for `c0mpute hosting publish <dir> --name <site>`.
|
|
4
4
|
*/
|
|
5
5
|
import { mkdir, writeFile, copyFile, readFile } from 'node:fs/promises';
|
|
6
|
+
import { pluginSet, keywordsFor, runPlugins, baseSlot } from './plugins.js';
|
|
6
7
|
import { createRequire } from 'node:module';
|
|
7
8
|
import { dirname, join } from 'node:path';
|
|
8
9
|
import { fileURLToPath } from 'node:url';
|
|
@@ -107,6 +108,7 @@ export function normalize(spec) {
|
|
|
107
108
|
look: LOOKS.includes(spec.look) ? spec.look : lookFor(name),
|
|
108
109
|
marquee: spec.marquee || `Welcome to ${name}! You are visitor #000${(name.length * 7919) % 9000 + 1000}. Sign the waitlist below!`,
|
|
109
110
|
crawlproof: spec.crawlproof === undefined ? (moshpit ? MOSHPIT_STATS_SITE : null) : spec.crawlproof,
|
|
111
|
+
plugins: pluginSet(spec.plugins),
|
|
110
112
|
ab: spec.ab === false ? null : { ...DEFAULT_AB, ...(spec.ab || {}) },
|
|
111
113
|
lang: spec.lang || 'en',
|
|
112
114
|
locale: spec.locale || 'en_US',
|
|
@@ -127,12 +129,15 @@ export function normalize(spec) {
|
|
|
127
129
|
s.description = spec.description || d.description;
|
|
128
130
|
s.summary = spec.summary || d.summary;
|
|
129
131
|
s.imageAlt = spec.imageAlt || d.imageAlt;
|
|
132
|
+
if (!s.plugins.has('ab')) s.ab = null;
|
|
133
|
+
if (!s.keywords.length) s.keywords = keywordsFor(s);
|
|
134
|
+
s.resourcesQuery = spec.resourcesQuery || '';
|
|
130
135
|
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;
|
|
131
136
|
return s;
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
|
|
135
|
-
export function pageHtml(s, { footers = '', noindex = false } = {}) {
|
|
140
|
+
export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s) } = {}) {
|
|
136
141
|
const points = s.points.length
|
|
137
142
|
? `<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>`
|
|
138
143
|
: '';
|
|
@@ -149,6 +154,7 @@ ${headTags(s, { noindex })}
|
|
|
149
154
|
<link rel="stylesheet" href="assets/charts.css">
|
|
150
155
|
<link rel="stylesheet" href="assets/waitlist.css">
|
|
151
156
|
${jsonLdTag(s)}
|
|
157
|
+
${slot.head.join('\n')}
|
|
152
158
|
</head>
|
|
153
159
|
<body class="waitlist-page">
|
|
154
160
|
<div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
|
|
@@ -159,24 +165,21 @@ ${jsonLdTag(s)}
|
|
|
159
165
|
<p class="waitlist-tagline">${esc(s.tagline)}</p>
|
|
160
166
|
<p class="waitlist-answer">${esc(s.summary)}</p>
|
|
161
167
|
${about}
|
|
162
|
-
|
|
163
|
-
<form class="stack" method="post" action="${esc(s.api)}/api/waitlist"><label for="wl-email">Email</label>
|
|
164
|
-
<div class="field-group"><input id="wl-email" name="email" type="email" autocomplete="email" required><button type="submit">${esc(s.button)}</button></div></form>
|
|
165
|
-
</waitlist-form>
|
|
168
|
+
${slot.hero.join('\n')}
|
|
166
169
|
</header>
|
|
167
170
|
<div class="grid" data-columns="2">
|
|
168
171
|
${points ? `<div class="card">${points}</div>` : ''}
|
|
169
|
-
|
|
170
|
-
<waitlist-stats dn="${esc(s.dn)}" api="${esc(s.api)}" days="30"></waitlist-stats>
|
|
171
|
-
</section>
|
|
172
|
+
${slot.cards.join('\n')}
|
|
172
173
|
</div>
|
|
173
|
-
${faqHtml(s)}
|
|
174
|
+
${s.plugins.has('faq') ? faqHtml(s, { comments: s.plugins.has('board') }) : ''}
|
|
175
|
+
${slot.sections.join('\n')}
|
|
174
176
|
<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>
|
|
175
177
|
</main>
|
|
176
178
|
<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>
|
|
177
179
|
${footers}
|
|
178
180
|
<script src="assets/charts.global.js"></script>
|
|
179
181
|
<script type="module" src="assets/waitlist.js"></script>
|
|
182
|
+
${slot.scripts.join('\n')}
|
|
180
183
|
${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
|
|
181
184
|
</body>
|
|
182
185
|
</html>
|
|
@@ -212,7 +215,7 @@ export async function renderFooters(s, { fetchImpl = globalThis.fetch } = {}) {
|
|
|
212
215
|
* Write the site for one spec into `out`. Returns the normalized spec.
|
|
213
216
|
* `images: false` skips the PNG renders (og.png, icons), e.g. where @resvg/resvg-js cannot load.
|
|
214
217
|
*/
|
|
215
|
-
export async function buildSite(spec, out, { footers = true, images = true, fetchImpl } = {}) {
|
|
218
|
+
export async function buildSite(spec, out, { footers = true, images = true, fetchImpl, cacheDir = null, maxAgeMs } = {}) {
|
|
216
219
|
const s = normalize(spec);
|
|
217
220
|
await mkdir(join(out, 'assets'), { recursive: true });
|
|
218
221
|
await mkdir(join(out, '.well-known'), { recursive: true });
|
|
@@ -233,8 +236,9 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
|
|
|
233
236
|
await writeFile(join(out, 'assets', 'icon-180.png'), await svgToPng(icon, { width: 180 }));
|
|
234
237
|
}
|
|
235
238
|
const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
|
|
236
|
-
await
|
|
237
|
-
await writeFile(join(out, '
|
|
239
|
+
const { slot } = await runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs });
|
|
240
|
+
await writeFile(join(out, 'index.html'), pageHtml(s, { footers: foot, slot }));
|
|
241
|
+
await writeFile(join(out, '404.html'), pageHtml(s, { footers: foot, noindex: true, slot }));
|
|
238
242
|
await writeFile(join(out, 'robots.txt'), robotsTxt(s));
|
|
239
243
|
await writeFile(join(out, 'sitemap.xml'), sitemapXml(s));
|
|
240
244
|
await writeFile(join(out, 'llms.txt'), llmsTxt(s));
|
package/src/plugins.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waitlist plugins: mix and match per site with `plugins` in sites.json. Every
|
|
3
|
+
* plugin is on unless the site says otherwise:
|
|
4
|
+
*
|
|
5
|
+
* "plugins": ["form", "board"] only these
|
|
6
|
+
* "plugins": { "faq": false } all but these
|
|
7
|
+
*
|
|
8
|
+
* A plugin adds HTML to named slots of the page and may write files:
|
|
9
|
+
* head, hero, cards, sections, scripts.
|
|
10
|
+
*/
|
|
11
|
+
import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
import { dirname, join } from 'node:path';
|
|
15
|
+
import { esc } from './seo.js';
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
export const PLUGINS = ['form', 'stats', 'ab', 'faq', 'resources', 'board', 'share', 'feed'];
|
|
20
|
+
|
|
21
|
+
/** Resolve a site's `plugins` setting to a Set (default: all of them). */
|
|
22
|
+
export function pluginSet(setting) {
|
|
23
|
+
if (Array.isArray(setting)) return new Set(setting.filter((p) => PLUGINS.includes(p)));
|
|
24
|
+
const on = new Set(PLUGINS);
|
|
25
|
+
if (setting && typeof setting === 'object') for (const [k, v] of Object.entries(setting)) if (v === false) on.delete(k);
|
|
26
|
+
return on;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const STOP = new Set('a an and are as at be by for from has have in into is it its of on or that the this to was we with you your our not yet will one all any get it\'s now new site'.split(' '));
|
|
30
|
+
|
|
31
|
+
/** Keywords for a site: its own list, else the name's labels and the tagline's meaningful words. */
|
|
32
|
+
export function keywordsFor(s) {
|
|
33
|
+
if (s.keywords?.length) return s.keywords.slice(0, 10);
|
|
34
|
+
const words = [...s.name.split('.'), ...String(s.tagline).toLowerCase().split(/[^a-z0-9+#-]+/)]
|
|
35
|
+
.map((w) => w.trim()).filter((w) => w.length > 2 && !STOP.has(w));
|
|
36
|
+
return [...new Set(words)].slice(0, 8);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resources from our own search (pit.world /api/search), fetched once at build and
|
|
41
|
+
* cached on disk by query so rebuilds do not search again. Never throws.
|
|
42
|
+
*/
|
|
43
|
+
export async function fetchResources(s, { fetchImpl = globalThis.fetch, cacheDir = null, limit = 8, endpoint = 'https://pit.world/api/search', maxAgeMs = 20 * 3600_000, now = Date.now() } = {}) {
|
|
44
|
+
const q = s.resourcesQuery || keywordsFor(s).slice(0, 4).join(' ');
|
|
45
|
+
if (!q) return { query: '', results: [] };
|
|
46
|
+
const key = createHash('sha256').update(q).digest('hex').slice(0, 16);
|
|
47
|
+
const cacheFile = cacheDir ? join(cacheDir, `${key}.json`) : null;
|
|
48
|
+
let stale = null;
|
|
49
|
+
if (cacheFile) {
|
|
50
|
+
try {
|
|
51
|
+
const c = JSON.parse(await readFile(cacheFile, 'utf8'));
|
|
52
|
+
if (now - Date.parse(c.fetchedAt) < maxAgeMs) return c;
|
|
53
|
+
stale = c; // refresh it, but keep it if the search fails
|
|
54
|
+
} catch { /* not cached */ }
|
|
55
|
+
}
|
|
56
|
+
let results = [];
|
|
57
|
+
try {
|
|
58
|
+
const r = await fetchImpl(`${endpoint}?q=${encodeURIComponent(q)}`, { headers: { accept: 'application/json', 'user-agent': '@profullstack/waitlist (+https://github.com/profullstack/waitlist)' }, signal: AbortSignal.timeout(20000) });
|
|
59
|
+
const body = r.ok ? await r.json() : {};
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
results = [...(body.featured || []), ...(body.results || [])]
|
|
62
|
+
.filter((x) => x && /^https?:\/\//.test(x.url) && !seen.has(x.url) && seen.add(x.url))
|
|
63
|
+
.slice(0, limit)
|
|
64
|
+
.map((x) => ({ url: x.url, title: String(x.title || x.url).slice(0, 140), summary: String(x.description || x.snippet || '').replace(/\s+/g, ' ').trim().slice(0, 300), host: new URL(x.url).hostname.replace(/^www\./, '') }));
|
|
65
|
+
} catch {
|
|
66
|
+
results = [];
|
|
67
|
+
}
|
|
68
|
+
if (!results.length && stale) return stale;
|
|
69
|
+
const out = { query: q, fetchedAt: new Date(now).toISOString(), results };
|
|
70
|
+
if (cacheFile && results.length) { await mkdir(cacheDir, { recursive: true }); await writeFile(cacheFile, JSON.stringify(out, null, 2)); }
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function resourcesHtml(s, res, { comments = false, share = false } = {}) {
|
|
75
|
+
const thread = (r) => comments ? `<comments-board compact dn="${esc(s.dn)}" api="${esc(s.api)}" item="${esc(r.url)}" subject="${esc(`Re: ${r.title}`.slice(0, 120))}"${share ? ' share' : ''}></comments-board>` : '';
|
|
76
|
+
if (!res?.results?.length) return '';
|
|
77
|
+
return `<section class="stack" aria-labelledby="resources"><h2 id="resources">Resources</h2>
|
|
78
|
+
<p class="muted">Useful reading on ${esc(s.title)} while you wait, from <a href="https://pit.world/search?q=${encodeURIComponent(res.query)}">pit.world search</a>.</p>
|
|
79
|
+
<ul role="list" class="grid" data-columns="2">${res.results.map((r) => `<li class="card stack" data-space="sm"><a href="${esc(r.url)}" rel="noopener"><strong>${esc(r.title)}</strong></a><small class="muted">${esc(r.host)}</small>${r.summary ? `<p>${esc(r.summary)}</p>` : ''}${thread(r)}</li>`).join('')}</ul>
|
|
80
|
+
</section>`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** RSS 2.0 + JSON Feed for syndication: the page itself, then its resources. */
|
|
84
|
+
export function feeds(s, res) {
|
|
85
|
+
const items = [
|
|
86
|
+
{ id: s.url, url: s.url, title: `${s.title}: ${s.tagline}`, summary: s.summary || s.tagline, date: `${s.updated}T00:00:00Z` },
|
|
87
|
+
...(res?.results || []).map((r) => ({ id: r.url, url: r.url, title: r.title, summary: r.summary, date: res.fetchedAt })),
|
|
88
|
+
];
|
|
89
|
+
const rss = `<?xml version="1.0" encoding="UTF-8"?>\n<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>${esc(s.title)}</title><link>${esc(s.url)}</link><atom:link href="${esc(s.url)}feed.xml" rel="self" type="application/rss+xml"/><description>${esc(s.tagline)}</description>${items.map((i) => `<item><title>${esc(i.title)}</title><link>${esc(i.url)}</link><guid>${esc(i.id)}</guid><pubDate>${new Date(i.date).toUTCString()}</pubDate><description>${esc(i.summary)}</description></item>`).join('')}</channel></rss>\n`;
|
|
90
|
+
const json = JSON.stringify({ version: 'https://jsonfeed.org/version/1.1', title: s.title, home_page_url: s.url, feed_url: `${s.url}feed.json`, description: s.tagline, items: items.map((i) => ({ id: i.id, url: i.url, title: i.title, summary: i.summary, date_published: new Date(i.date).toISOString() })) }, null, 2) + '\n';
|
|
91
|
+
return { rss, json };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The plugins that need no build step (form, stats), as page slots. */
|
|
95
|
+
export function baseSlot(s) {
|
|
96
|
+
const on = s.plugins || pluginSet();
|
|
97
|
+
const slot = { head: [], hero: [], cards: [], sections: [], scripts: [] };
|
|
98
|
+
if (on.has('form')) {
|
|
99
|
+
slot.hero.push(`<waitlist-form dn="${esc(s.dn)}" api="${esc(s.api)}" button="${esc(s.button)}">
|
|
100
|
+
<form class="stack" method="post" action="${esc(s.api)}/api/waitlist"><label for="wl-email">Email</label>
|
|
101
|
+
<div class="field-group"><input id="wl-email" name="email" type="email" autocomplete="email" required><button type="submit">${esc(s.button)}</button></div></form>
|
|
102
|
+
</waitlist-form>`);
|
|
103
|
+
}
|
|
104
|
+
if (on.has('stats')) {
|
|
105
|
+
slot.cards.push(`<section class="card stack" aria-labelledby="count"><h2 id="count">Who's waiting</h2>
|
|
106
|
+
<waitlist-stats dn="${esc(s.dn)}" api="${esc(s.api)}" days="30"></waitlist-stats></section>`);
|
|
107
|
+
}
|
|
108
|
+
return slot;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 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 } = {}) {
|
|
113
|
+
const on = s.plugins;
|
|
114
|
+
const slot = baseSlot(s);
|
|
115
|
+
let res = null;
|
|
116
|
+
if (on.has('resources')) {
|
|
117
|
+
res = await fetchResources(s, { fetchImpl, cacheDir, maxAgeMs });
|
|
118
|
+
slot.sections.push(resourcesHtml(s, res, { comments: on.has('board'), share: on.has('share') }));
|
|
119
|
+
if (res.results.length) await writeFile(join(out, 'resources.json'), JSON.stringify(res, null, 2) + '\n');
|
|
120
|
+
}
|
|
121
|
+
if (on.has('board')) {
|
|
122
|
+
const dir = dirname(require.resolve('@profullstack/comments'));
|
|
123
|
+
await copyFile(join(dir, 'index.js'), join(out, 'assets', 'comments.js'));
|
|
124
|
+
await copyFile(join(dir, 'core.js'), join(out, 'assets', 'core.js'));
|
|
125
|
+
slot.sections.push(`<comments-board dn="${esc(s.dn)}" api="${esc(s.api)}" feed${on.has('share') ? ' share' : ''} title="Discussion"></comments-board>`);
|
|
126
|
+
slot.scripts.push('<script type="module" src="assets/comments.js"></script>');
|
|
127
|
+
slot.head.push(`<link rel="alternate" type="application/rss+xml" title="${esc(s.title)} discussion" href="${esc(s.api)}/api/comments/feed?dn=${encodeURIComponent(s.dn)}">`);
|
|
128
|
+
}
|
|
129
|
+
if (on.has('feed')) {
|
|
130
|
+
const f = feeds(s, res);
|
|
131
|
+
await writeFile(join(out, 'feed.xml'), f.rss);
|
|
132
|
+
await writeFile(join(out, 'feed.json'), f.json);
|
|
133
|
+
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">`);
|
|
134
|
+
}
|
|
135
|
+
return { slot, resources: res };
|
|
136
|
+
}
|
package/src/seo.js
CHANGED
|
@@ -152,10 +152,11 @@ export function jsonLdTag(s) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/** The visible FAQ section: same questions as the FAQPage JSON-LD. */
|
|
155
|
-
export function faqHtml(s) {
|
|
155
|
+
export function faqHtml(s, { comments = false } = {}) {
|
|
156
156
|
if (!s.faq.length) return '';
|
|
157
|
+
const thread = (f, i) => comments ? `<comments-board compact dn="${esc(s.dn)}" api="${esc(s.api)}" item="faq:${i + 1}" subject="${esc(`Re: ${f.q}`.slice(0, 120))}"></comments-board>` : '';
|
|
157
158
|
return `<section class="card stack waitlist-faq" aria-labelledby="faq"><h2 id="faq">Questions</h2>
|
|
158
|
-
${s.faq.map((f) => `<details><summary>${esc(f.q)}</summary><p>${esc(f.a)}</p
|
|
159
|
+
${s.faq.map((f, i) => `<details><summary>${esc(f.q)}</summary><p>${esc(f.a)}</p>${thread(f, i)}</details>`).join('\n ')}
|
|
159
160
|
</section>`;
|
|
160
161
|
}
|
|
161
162
|
|