@profullstack/waitlist 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +90 -2
- package/bin/waitlist.js +60 -0
- package/package.json +51 -4
- package/src/build.js +226 -0
- package/src/index.js +248 -0
- package/src/seo.js +327 -0
- package/src/waitlist.css +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Profullstack, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @profullstack/waitlist
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An email waitlist for any launch page: a `<waitlist-form>` web component, a live signup
|
|
4
|
+
chart drawn with [@profullstack/charts](https://www.npmjs.com/package/@profullstack/charts),
|
|
5
|
+
and a static-site builder on [@profullstack/css](https://www.npmjs.com/package/@profullstack/css)
|
|
6
|
+
with its retro **looks** (neon, matrix, terminal, amber CRT, synthwave, GeoCities, vaporwave).
|
|
7
|
+
No server of your own: sites publish to c0mpute hosting and signups go to the house waitlist API.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @profullstack/waitlist
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Build a site
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx @profullstack/waitlist build --name alt.atheism \
|
|
17
|
+
--tagline "Arguing about god since 1989." --point "Threaded discussion" --look geocities --out site
|
|
18
|
+
c0mpute hosting publish site --name waitlist-alt-atheism
|
|
19
|
+
moshcode name c0mpute alt.atheism <site_id> # https://alt.atheism and alt.atheism.pit.world
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`waitlist build-many sites.json --out sites` builds one folder per entry
|
|
23
|
+
(`[{ name, title, tagline, about, points, look, kicker }]`).
|
|
24
|
+
|
|
25
|
+
Each site gets `index.html`, `404.html`, `og.png`, `llms.txt`, `robots.txt`, `sitemap.xml`, the CSS and chart
|
|
26
|
+
assets, the Profullstack webring footer and (for Moshpit names) the pit.world footer, plus
|
|
27
|
+
the network's crawlproof tag. Leave `--look` out and one is picked from the name: `comp.*`
|
|
28
|
+
terminal, `alt.*` GeoCities, `sci.*` matrix, `rec.*` synthwave, `soc.*` vaporwave,
|
|
29
|
+
`news.*` amber, `talk.*` neon.
|
|
30
|
+
|
|
31
|
+
## SEO, social cards, AEO and GEO
|
|
32
|
+
|
|
33
|
+
Every site is built with its own search and share metadata, written from that site's name,
|
|
34
|
+
tagline and points (no generic copy):
|
|
35
|
+
|
|
36
|
+
- **Head:** unique `<title>`, meta description (160 chars max), canonical, robots,
|
|
37
|
+
theme-color (the look's canvas), SVG + PNG icons, `lang`.
|
|
38
|
+
- **Social:** `og:*` (title, description, url, type, site_name, locale, image with
|
|
39
|
+
width/height/alt) and `twitter:card=summary_large_image`.
|
|
40
|
+
- **`og.png`:** a real 1200x630 PNG rendered at build time in the site's look (colors,
|
|
41
|
+
type, decoration) with its name, tagline and call to action, via `@resvg/resvg-js`
|
|
42
|
+
(prebuilt, no system deps). `og.svg` sits next to it.
|
|
43
|
+
- **AEO:** JSON-LD `@graph` with WebSite, Organization, WebPage and FAQPage. The same 3-5
|
|
44
|
+
Q&As show on the page as a visible FAQ, under an answer-first summary.
|
|
45
|
+
- **GEO:** `/llms.txt` (what it is, status: waitlist, how to join, FAQ), `sitemap.xml`
|
|
46
|
+
(with the image), `robots.txt` that names and allows the AI crawlers (GPTBot,
|
|
47
|
+
ClaudeBot, PerplexityBot, Google-Extended, ...), and an IndexNow key file;
|
|
48
|
+
`waitlist indexnow sites.json` pings IndexNow after publishing.
|
|
49
|
+
|
|
50
|
+
Canonical URL: a Moshpit name only resolves through a Moshpit-aware resolver, so its
|
|
51
|
+
canonical (and every absolute URL in the cards) is the pit.world relay,
|
|
52
|
+
`https://<name>.pit.world/`, with `https://<name>/` as the alternate. Clearnet names use
|
|
53
|
+
`https://<name>/`.
|
|
54
|
+
|
|
55
|
+
Override anything per site in `sites.json`: `url`, `nativeUrl`, `image`, `imageAlt`,
|
|
56
|
+
`seoTitle`, `description`, `summary`, `faq` (`[{ q, a }]`), `keywords`, `sameAs`,
|
|
57
|
+
`audience`, `lang`, `locale`, `siteName`, `themeColor`, `twitter`, `publisher`,
|
|
58
|
+
`schema` (extra JSON-LD nodes), `indexnowKey`, `updated`.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { normalize } from '@profullstack/waitlist/build';
|
|
62
|
+
import { headTags, jsonLd, llmsTxt, ogSvg, svgToPng } from '@profullstack/waitlist/seo';
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Use the components on any page
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<link rel="stylesheet" href="https://unpkg.com/@profullstack/css/css/profullstack.css">
|
|
69
|
+
<link rel="stylesheet" href="https://unpkg.com/@profullstack/css/css/looks.css">
|
|
70
|
+
<script src="https://unpkg.com/@profullstack/charts/dist/charts.global.js"></script>
|
|
71
|
+
<script type="module" src="https://unpkg.com/@profullstack/waitlist/src/index.js"></script>
|
|
72
|
+
|
|
73
|
+
<waitlist-form dn="example.com"></waitlist-form>
|
|
74
|
+
<waitlist-stats dn="example.com" days="30"></waitlist-stats>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Attributes: `dn` (the list; defaults to the page's host), `api` (default
|
|
78
|
+
`https://moshcoding.com`), `button`, `label`, `placeholder`. A successful signup fires
|
|
79
|
+
`waitlist:joined`. From JavaScript: `join({ email, dn })`, `stats({ dn })`.
|
|
80
|
+
|
|
81
|
+
## The API
|
|
82
|
+
|
|
83
|
+
Any server with these two routes works (moshcoding.com runs them: double opt-in email,
|
|
84
|
+
a list per domain in the owner's dashboard, `waitlist.signup` domain webhooks):
|
|
85
|
+
|
|
86
|
+
- `POST /api/waitlist` `{ email, dn, ref? }` -> `{ ok, pending, already }` or `{ error }`
|
|
87
|
+
- `GET /api/waitlist/stats?dn=&days=` -> `{ total, verified, days: [{ day, n }] }` (counts only)
|
|
88
|
+
|
|
89
|
+
Both send `Access-Control-Allow-Origin: *`.
|
|
90
|
+
|
|
91
|
+
MIT
|
package/bin/waitlist.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { buildSite, buildMany, readSpecs, normalize } from '../src/build.js';
|
|
3
|
+
import { pingIndexNow } from '../src/seo.js';
|
|
4
|
+
|
|
5
|
+
const HELP = `waitlist: build static waitlist sites (@profullstack/css + @profullstack/charts)
|
|
6
|
+
|
|
7
|
+
usage:
|
|
8
|
+
waitlist build --name <name> [--title T] [--tagline T] [--about T] [--point P]... [--out dir]
|
|
9
|
+
waitlist build-many <sites.json> [--out dir] one folder per site under --out
|
|
10
|
+
waitlist indexnow <sites.json> ping IndexNow for every site (after publishing)
|
|
11
|
+
|
|
12
|
+
flags:
|
|
13
|
+
--api <url> waitlist API (default https://moshcoding.com)
|
|
14
|
+
--host <host> public host (default <name>.pit.world for Moshpit names)
|
|
15
|
+
--url <url> canonical URL (default https://<host>/)
|
|
16
|
+
--image <url> og:image URL (default <url>og.png, rendered at build time)
|
|
17
|
+
--description <t> meta description (default: derived from tagline + points)
|
|
18
|
+
--theme dark|light
|
|
19
|
+
--look <look> neon|matrix|terminal|amber|synthwave|geocities|vaporwave (default: picked from the name)
|
|
20
|
+
--no-footers skip the webring + pit.world footers (offline builds)
|
|
21
|
+
--no-images skip the PNG renders (og.png, icons)
|
|
22
|
+
|
|
23
|
+
Every site field (seoTitle, description, summary, faq, image, imageAlt, keywords, sameAs,
|
|
24
|
+
audience, lang, locale, themeColor, twitter, schema, ...) can be set per site in sites.json.
|
|
25
|
+
|
|
26
|
+
publish: c0mpute hosting publish <dir> --name waitlist-<name>
|
|
27
|
+
moshcode name c0mpute <name> <site_id>`;
|
|
28
|
+
|
|
29
|
+
const argv = process.argv.slice(2);
|
|
30
|
+
const cmd = argv.shift();
|
|
31
|
+
const flags = { point: [] };
|
|
32
|
+
const pos = [];
|
|
33
|
+
for (let i = 0; i < argv.length; i++) {
|
|
34
|
+
const a = argv[i];
|
|
35
|
+
if (a === '--no-footers') flags.footers = false;
|
|
36
|
+
else if (a === '--no-images') flags.images = false;
|
|
37
|
+
else if (a.startsWith('--')) {
|
|
38
|
+
const k = a.slice(2);
|
|
39
|
+
const v = argv[++i];
|
|
40
|
+
if (k === 'point') flags.point.push(v);
|
|
41
|
+
else flags[k] = v;
|
|
42
|
+
} else pos.push(a);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const opts = { footers: flags.footers !== false, images: flags.images !== false };
|
|
46
|
+
const pick = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
47
|
+
if (cmd === 'build') {
|
|
48
|
+
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);
|
|
49
|
+
console.log(`built ${s.name} -> ${flags.out || `./${s.name}`}`);
|
|
50
|
+
} else if (cmd === 'build-many' && pos[0]) {
|
|
51
|
+
const specs = await readSpecs(pos[0]);
|
|
52
|
+
const done = await buildMany(specs.map((s) => ({ ...pick({ api: flags.api, theme: flags.theme }), ...s })), flags.out || './sites', opts);
|
|
53
|
+
console.log(`built ${done.length} sites -> ${flags.out || './sites'}`);
|
|
54
|
+
} else if (cmd === 'indexnow' && pos[0]) {
|
|
55
|
+
const sites = (await readSpecs(pos[0])).map(normalize);
|
|
56
|
+
for (const r of await pingIndexNow(sites)) console.log(`${r.host}\t${r.status}${r.error ? `\t${r.error}` : ''}`);
|
|
57
|
+
} else {
|
|
58
|
+
console.log(HELP);
|
|
59
|
+
process.exit(cmd && cmd !== 'help' && cmd !== '--help' ? 1 : 0);
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profullstack/waitlist",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Profullstack, Inc.",
|
|
8
|
+
"homepage": "https://github.com/profullstack/waitlist#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/profullstack/waitlist.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"waitlist",
|
|
15
|
+
"launch",
|
|
16
|
+
"landing-page",
|
|
17
|
+
"web-component",
|
|
18
|
+
"static-site",
|
|
19
|
+
"c0mpute",
|
|
20
|
+
"moshpit",
|
|
21
|
+
"seo",
|
|
22
|
+
"open-graph",
|
|
23
|
+
"llms-txt"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./src/index.js",
|
|
27
|
+
"./build": "./src/build.js",
|
|
28
|
+
"./seo": "./src/seo.js",
|
|
29
|
+
"./waitlist.css": "./src/waitlist.css",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"bin": {
|
|
33
|
+
"waitlist": "bin/waitlist.js"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src",
|
|
37
|
+
"bin",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=20"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"test": "node --test"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@profullstack/charts": "^0.3.0",
|
|
49
|
+
"@profullstack/css": "^0.4.0",
|
|
50
|
+
"@profullstack/footer": "^0.7.3",
|
|
51
|
+
"@resvg/resvg-js": "^2.6.2"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/build.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @profullstack/waitlist/build: write a complete static waitlist site (no server)
|
|
3
|
+
* for one name, ready for `c0mpute hosting publish <dir> --name <site>`.
|
|
4
|
+
*/
|
|
5
|
+
import { mkdir, writeFile, copyFile, readFile } from 'node:fs/promises';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import {
|
|
10
|
+
esc, seoDefaults, headTags, jsonLdTag, faqHtml, llmsTxt, robotsTxt, sitemapXml,
|
|
11
|
+
indexNowKey, ogSvg, iconSvg as lookIconSvg, svgToPng,
|
|
12
|
+
} from './seo.js';
|
|
13
|
+
|
|
14
|
+
export { esc };
|
|
15
|
+
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
|
|
19
|
+
/** The crawlproof project every Moshpit landing and parked page reports to. */
|
|
20
|
+
export const MOSHPIT_STATS_SITE = '2cbffe9d-1b6e-43f0-85f3-3cadee132048';
|
|
21
|
+
|
|
22
|
+
/** Every look @profullstack/css/looks ships. */
|
|
23
|
+
export const LOOKS = ['neon', 'matrix', 'terminal', 'amber', 'synthwave', 'geocities', 'vaporwave'];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A look that fits the name when none is given: newsgroup hierarchies get their
|
|
27
|
+
* era (comp.* a terminal, alt.* a GeoCities page, sci.* the matrix, rec.* synthwave),
|
|
28
|
+
* anything else a stable pick from the name.
|
|
29
|
+
*/
|
|
30
|
+
export function lookFor(name) {
|
|
31
|
+
const first = name.split('.')[0];
|
|
32
|
+
const byPrefix = { comp: 'terminal', news: 'amber', alt: 'geocities', sci: 'matrix', rec: 'synthwave', soc: 'vaporwave', talk: 'neon', misc: 'amber' };
|
|
33
|
+
if (byPrefix[first]) return byPrefix[first];
|
|
34
|
+
const ending = name.split('.').pop();
|
|
35
|
+
const byEnding = { cli: 'terminal', pit: 'terminal', dns: 'terminal', v6: 'terminal', onions: 'matrix', agent: 'matrix', desktop: 'vaporwave', politics: 'neon', lobby: 'amber', whatever: 'geocities', yeah: 'synthwave', rank: 'neon' };
|
|
36
|
+
if (byEnding[ending]) return byEnding[ending];
|
|
37
|
+
let h = 0;
|
|
38
|
+
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
|
|
39
|
+
return LOOKS[h % LOOKS.length];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A Moshpit name (label.ending, no dot-TLD of the old internet) -> its pit.world relay host. */
|
|
43
|
+
export function relayHost(name) {
|
|
44
|
+
return name.endsWith('.pit.world') ? name : `${name}.pit.world`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function withSlash(u) {
|
|
48
|
+
return u.endsWith('/') ? u : `${u}/`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Fill defaults and validate one site spec. Every field below can be set per site in
|
|
53
|
+
* sites.json; SEO fields (seoTitle, description, summary, imageAlt, faq) are derived
|
|
54
|
+
* from the site's own name, tagline and points when left out.
|
|
55
|
+
*/
|
|
56
|
+
export function normalize(spec) {
|
|
57
|
+
const name = String(spec.name || '').trim().toLowerCase();
|
|
58
|
+
if (!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(name)) throw new Error(`bad name: ${spec.name}`);
|
|
59
|
+
const moshpit = spec.moshpit ?? !/\.(com|org|net|io|dev|app|sh|xyz|me|info|co|ai)$/.test(name);
|
|
60
|
+
const host = spec.host || (moshpit ? relayHost(name) : name);
|
|
61
|
+
// Canonical: the host a crawler can resolve. A Moshpit name only resolves through a
|
|
62
|
+
// Moshpit-aware resolver, so its canonical is the pit.world relay and https://<name> the alternate.
|
|
63
|
+
const url = withSlash(spec.url || `https://${host}/`);
|
|
64
|
+
const s = {
|
|
65
|
+
name,
|
|
66
|
+
host,
|
|
67
|
+
moshpit,
|
|
68
|
+
url,
|
|
69
|
+
nativeUrl: withSlash(spec.nativeUrl || (moshpit ? `https://${name}/` : url)),
|
|
70
|
+
dn: spec.dn || name,
|
|
71
|
+
title: spec.title || name,
|
|
72
|
+
tagline: spec.tagline || `${name} is coming soon.`,
|
|
73
|
+
about: spec.about || '',
|
|
74
|
+
points: Array.isArray(spec.points) ? spec.points : [],
|
|
75
|
+
kicker: spec.kicker || (moshpit ? 'Coming soon on the Moshpit' : 'Coming soon'),
|
|
76
|
+
button: spec.button || 'Join the waitlist',
|
|
77
|
+
api: (spec.api || 'https://moshcoding.com').replace(/\/$/, ''),
|
|
78
|
+
theme: spec.theme || 'dark',
|
|
79
|
+
look: LOOKS.includes(spec.look) ? spec.look : lookFor(name),
|
|
80
|
+
marquee: spec.marquee || `Welcome to ${name}! You are visitor #000${(name.length * 7919) % 9000 + 1000}. Sign the waitlist below!`,
|
|
81
|
+
crawlproof: spec.crawlproof === undefined ? (moshpit ? MOSHPIT_STATS_SITE : null) : spec.crawlproof,
|
|
82
|
+
lang: spec.lang || 'en',
|
|
83
|
+
locale: spec.locale || 'en_US',
|
|
84
|
+
siteName: spec.siteName || spec.title || name,
|
|
85
|
+
image: spec.image || `${url}og.png`,
|
|
86
|
+
themeColor: spec.themeColor || null,
|
|
87
|
+
twitter: spec.twitter || null,
|
|
88
|
+
keywords: Array.isArray(spec.keywords) ? spec.keywords : [],
|
|
89
|
+
sameAs: Array.isArray(spec.sameAs) ? spec.sameAs : [],
|
|
90
|
+
publisher: spec.publisher === undefined ? { name: 'Profullstack', url: 'https://profullstack.com' } : spec.publisher,
|
|
91
|
+
schema: spec.schema || null,
|
|
92
|
+
audience: spec.audience || '',
|
|
93
|
+
indexnowKey: spec.indexnowKey || indexNowKey(name),
|
|
94
|
+
updated: spec.updated || new Date().toISOString().slice(0, 10),
|
|
95
|
+
};
|
|
96
|
+
const d = seoDefaults(s);
|
|
97
|
+
s.seoTitle = spec.seoTitle || d.seoTitle;
|
|
98
|
+
s.description = spec.description || d.description;
|
|
99
|
+
s.summary = spec.summary || d.summary;
|
|
100
|
+
s.imageAlt = spec.imageAlt || d.imageAlt;
|
|
101
|
+
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;
|
|
102
|
+
return s;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The page HTML. `footers` is pre-rendered HTML (webring row, pit.world footer) placed last. */
|
|
106
|
+
export function pageHtml(s, { footers = '', noindex = false } = {}) {
|
|
107
|
+
const points = s.points.length
|
|
108
|
+
? `<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>`
|
|
109
|
+
: '';
|
|
110
|
+
const about = s.about ? `<p>${esc(s.about)}</p>` : '';
|
|
111
|
+
return `<!doctype html>
|
|
112
|
+
<html lang="${esc(s.lang)}" data-theme="${esc(s.theme)}" data-look="${esc(s.look)}">
|
|
113
|
+
<head>
|
|
114
|
+
<meta charset="utf-8">
|
|
115
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
116
|
+
${headTags(s, { noindex })}
|
|
117
|
+
<link rel="stylesheet" href="assets/profullstack.css">
|
|
118
|
+
<link rel="stylesheet" href="assets/looks.css">
|
|
119
|
+
<link rel="stylesheet" href="assets/charts.css">
|
|
120
|
+
<link rel="stylesheet" href="assets/waitlist.css">
|
|
121
|
+
${jsonLdTag(s)}
|
|
122
|
+
</head>
|
|
123
|
+
<body class="waitlist-page">
|
|
124
|
+
<div data-look-marquee aria-hidden="true"><span>${esc(s.marquee)}</span></div>
|
|
125
|
+
<main class="container">
|
|
126
|
+
<header class="waitlist-hero stack" data-space="lg">
|
|
127
|
+
<p class="waitlist-kicker"><span class="badge">${esc(s.kicker)}</span></p>
|
|
128
|
+
<h1>${esc(s.title)}</h1>
|
|
129
|
+
<p class="waitlist-tagline">${esc(s.tagline)}</p>
|
|
130
|
+
<p class="waitlist-answer">${esc(s.summary)}</p>
|
|
131
|
+
${about}
|
|
132
|
+
<waitlist-form dn="${esc(s.dn)}" api="${esc(s.api)}" button="${esc(s.button)}">
|
|
133
|
+
<form class="stack" method="post" action="${esc(s.api)}/api/waitlist"><label for="wl-email">Email</label>
|
|
134
|
+
<div class="field-group"><input id="wl-email" name="email" type="email" autocomplete="email" required><button type="submit">${esc(s.button)}</button></div></form>
|
|
135
|
+
</waitlist-form>
|
|
136
|
+
</header>
|
|
137
|
+
<div class="grid" data-columns="2">
|
|
138
|
+
${points ? `<div class="card">${points}</div>` : ''}
|
|
139
|
+
<section class="card stack" aria-labelledby="count"><h2 id="count">Who's waiting</h2>
|
|
140
|
+
<waitlist-stats dn="${esc(s.dn)}" api="${esc(s.api)}" days="30"></waitlist-stats>
|
|
141
|
+
</section>
|
|
142
|
+
</div>
|
|
143
|
+
${faqHtml(s)}
|
|
144
|
+
<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>
|
|
145
|
+
</main>
|
|
146
|
+
<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>
|
|
147
|
+
${footers}
|
|
148
|
+
<script src="assets/charts.global.js"></script>
|
|
149
|
+
<script type="module" src="assets/waitlist.js"></script>
|
|
150
|
+
${s.crawlproof ? `<script defer data-site="${esc(s.crawlproof)}" src="https://crawlproof.com/stats.js"></script>` : ''}
|
|
151
|
+
</body>
|
|
152
|
+
</html>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Square icon in the look's colors (takes a normalized spec or a bare name). */
|
|
157
|
+
export function iconSvg(s) {
|
|
158
|
+
return lookIconSvg(typeof s === 'string' ? normalize({ name: s }) : s);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Render the shared footers for a host: the Profullstack webring row, then (Moshpit names only) the pit.world footer. */
|
|
162
|
+
export async function renderFooters(s, { fetchImpl = globalThis.fetch } = {}) {
|
|
163
|
+
let out = '';
|
|
164
|
+
try {
|
|
165
|
+
const { footerHtml } = await import('@profullstack/footer');
|
|
166
|
+
out += await footerHtml({ site: `https://${s.host}/`, since: 2026 });
|
|
167
|
+
} catch (err) {
|
|
168
|
+
process.emitWarning(`webring footer skipped for ${s.host}: ${err.message}`);
|
|
169
|
+
}
|
|
170
|
+
if (s.moshpit) {
|
|
171
|
+
try {
|
|
172
|
+
const res = await fetchImpl(`https://pit.world/snippets/footer.html?site=${encodeURIComponent(s.host)}`);
|
|
173
|
+
if (res.ok) out += '\n' + (await res.text());
|
|
174
|
+
} catch (err) {
|
|
175
|
+
process.emitWarning(`pit.world footer skipped for ${s.host}: ${err.message}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Write the site for one spec into `out`. Returns the normalized spec.
|
|
183
|
+
* `images: false` skips the PNG renders (og.png, icons), e.g. where @resvg/resvg-js cannot load.
|
|
184
|
+
*/
|
|
185
|
+
export async function buildSite(spec, out, { footers = true, images = true, fetchImpl } = {}) {
|
|
186
|
+
const s = normalize(spec);
|
|
187
|
+
await mkdir(join(out, 'assets'), { recursive: true });
|
|
188
|
+
await mkdir(join(out, '.well-known'), { recursive: true });
|
|
189
|
+
const cssDir = dirname(require.resolve('@profullstack/css/css'));
|
|
190
|
+
for (const f of ['profullstack.css', 'tokens.css', 'widgets.css', 'platform.css', 'looks.css']) await copyFile(join(cssDir, f), join(out, 'assets', f));
|
|
191
|
+
const chartsDir = dirname(require.resolve('@profullstack/charts/global'));
|
|
192
|
+
await copyFile(join(chartsDir, 'charts.global.js'), join(out, 'assets', 'charts.global.js'));
|
|
193
|
+
await copyFile(join(chartsDir, 'charts.css'), join(out, 'assets', 'charts.css'));
|
|
194
|
+
await copyFile(join(here, 'index.js'), join(out, 'assets', 'waitlist.js'));
|
|
195
|
+
await copyFile(join(here, 'waitlist.css'), join(out, 'assets', 'waitlist.css'));
|
|
196
|
+
const icon = iconSvg(s);
|
|
197
|
+
await writeFile(join(out, 'assets', 'icon.svg'), icon);
|
|
198
|
+
const og = ogSvg(s);
|
|
199
|
+
await writeFile(join(out, 'og.svg'), og);
|
|
200
|
+
if (images) {
|
|
201
|
+
await writeFile(join(out, 'og.png'), await svgToPng(og));
|
|
202
|
+
await writeFile(join(out, 'assets', 'icon-192.png'), await svgToPng(icon, { width: 192 }));
|
|
203
|
+
await writeFile(join(out, 'assets', 'icon-180.png'), await svgToPng(icon, { width: 180 }));
|
|
204
|
+
}
|
|
205
|
+
const foot = footers ? await renderFooters(s, { fetchImpl }) : '';
|
|
206
|
+
await writeFile(join(out, 'index.html'), pageHtml(s, { footers: foot }));
|
|
207
|
+
await writeFile(join(out, '404.html'), pageHtml(s, { footers: foot, noindex: true }));
|
|
208
|
+
await writeFile(join(out, 'robots.txt'), robotsTxt(s));
|
|
209
|
+
await writeFile(join(out, 'sitemap.xml'), sitemapXml(s));
|
|
210
|
+
await writeFile(join(out, 'llms.txt'), llmsTxt(s));
|
|
211
|
+
await writeFile(join(out, `${s.indexnowKey}.txt`), `${s.indexnowKey}\n`);
|
|
212
|
+
await writeFile(join(out, '.well-known', 'openwebring.json'), JSON.stringify({ name: s.title, url: s.url, ring: 'profullstack', description: s.tagline }, null, 2) + '\n');
|
|
213
|
+
return s;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Build many: specs is an array; each lands in `${outRoot}/${name}`. */
|
|
217
|
+
export async function buildMany(specs, outRoot, opts = {}) {
|
|
218
|
+
const done = [];
|
|
219
|
+
for (const spec of specs) done.push(await buildSite(spec, join(outRoot, spec.name), opts));
|
|
220
|
+
return done;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function readSpecs(file) {
|
|
224
|
+
const data = JSON.parse(await readFile(file, 'utf8'));
|
|
225
|
+
return Array.isArray(data) ? data : data.sites;
|
|
226
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @profullstack/waitlist: the browser side.
|
|
3
|
+
*
|
|
4
|
+
* <waitlist-form dn="alt.atheism"></waitlist-form>
|
|
5
|
+
* <waitlist-stats dn="alt.atheism"></waitlist-stats>
|
|
6
|
+
* <script type="module">import '@profullstack/waitlist';</script>
|
|
7
|
+
*
|
|
8
|
+
* Signups go to the house waitlist API (moshcoding.com, double opt-in, one list per
|
|
9
|
+
* domain, shown to the domain owner in the moshcoding dashboard). Point `api` at any
|
|
10
|
+
* server that speaks the same two routes:
|
|
11
|
+
* POST {api}/api/waitlist {email, dn, ref?} -> {ok, pending, already} | {error}
|
|
12
|
+
* GET {api}/api/waitlist/stats ?dn=&days= -> {total, verified, days:[{day,n}]}
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const DEFAULT_API = 'https://moshcoding.com';
|
|
16
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
|
|
17
|
+
|
|
18
|
+
/** Trimmed email when it looks valid, else null. */
|
|
19
|
+
export function cleanEmail(raw) {
|
|
20
|
+
const e = String(raw ?? '').trim();
|
|
21
|
+
return EMAIL_RE.test(e) && e.length <= 254 ? e : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** ?ref=<code> from a URL, URL-safe and bounded, or null. */
|
|
25
|
+
export function refFrom(href) {
|
|
26
|
+
try {
|
|
27
|
+
const r = new URL(href).searchParams.get('ref') || '';
|
|
28
|
+
return r.replace(/[^A-Za-z0-9_-]/g, '').slice(0, 64) || null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The message to show for an API answer. */
|
|
35
|
+
export function messageFor(res, email) {
|
|
36
|
+
if (res && res.ok) {
|
|
37
|
+
if (res.pending) return { tone: 'success', text: `Almost there: we sent a confirmation link to ${email}.` };
|
|
38
|
+
if (res.already) return { tone: 'success', text: `${email} is already on the list.` };
|
|
39
|
+
return { tone: 'success', text: `You're on the list, ${email}.` };
|
|
40
|
+
}
|
|
41
|
+
return { tone: 'danger', text: (res && res.error) || 'Could not save that. Try again.' };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** POST one signup. Resolves to the API body plus `status`; never throws on HTTP errors. */
|
|
45
|
+
export async function join({ email, dn, ref = null, api = DEFAULT_API, fetchImpl = globalThis.fetch }) {
|
|
46
|
+
const clean = cleanEmail(email);
|
|
47
|
+
if (!clean) return { ok: false, status: 400, error: "That doesn't look like an email." };
|
|
48
|
+
try {
|
|
49
|
+
const res = await fetchImpl(new URL('/api/waitlist', api).href, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: { 'content-type': 'application/json' },
|
|
52
|
+
body: JSON.stringify({ email: clean, dn, ref }),
|
|
53
|
+
});
|
|
54
|
+
const body = await res.json().catch(() => ({}));
|
|
55
|
+
return { ...body, ok: Boolean(res.ok && body.ok), status: res.status };
|
|
56
|
+
} catch (err) {
|
|
57
|
+
return { ok: false, status: 0, error: 'Could not reach the waitlist. Try again.' };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** GET the public, email-free counts for a domain. Null when unavailable. */
|
|
62
|
+
export async function stats({ dn, days = 30, api = DEFAULT_API, fetchImpl = globalThis.fetch }) {
|
|
63
|
+
try {
|
|
64
|
+
const u = new URL('/api/waitlist/stats', api);
|
|
65
|
+
u.searchParams.set('dn', dn);
|
|
66
|
+
u.searchParams.set('days', String(days));
|
|
67
|
+
const res = await fetchImpl(u.href);
|
|
68
|
+
if (!res.ok) return null;
|
|
69
|
+
return await res.json();
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const HTMLElementBase = globalThis.HTMLElement ?? class {};
|
|
76
|
+
|
|
77
|
+
/** <waitlist-form dn="name" [api] [button] [placeholder] [label]>: light DOM, styled by @profullstack/css. */
|
|
78
|
+
export class WaitlistForm extends HTMLElementBase {
|
|
79
|
+
connectedCallback() {
|
|
80
|
+
if (this.dataset.ready) return;
|
|
81
|
+
this.dataset.ready = '1';
|
|
82
|
+
const id = `wl-${Math.random().toString(36).slice(2, 8)}`;
|
|
83
|
+
this.innerHTML = `
|
|
84
|
+
<form class="stack waitlist-form" novalidate>
|
|
85
|
+
<label for="${id}">${esc(this.getAttribute('label') || 'Email')}</label>
|
|
86
|
+
<div class="field-group">
|
|
87
|
+
<input id="${id}" name="email" type="email" autocomplete="email" required
|
|
88
|
+
placeholder="${esc(this.getAttribute('placeholder') || 'you@example.com')}" aria-describedby="${id}-msg">
|
|
89
|
+
<button type="submit">${esc(this.getAttribute('button') || 'Join the waitlist')}</button>
|
|
90
|
+
</div>
|
|
91
|
+
<p id="${id}-msg" class="alert" role="status" hidden></p>
|
|
92
|
+
</form>`;
|
|
93
|
+
const form = this.querySelector('form');
|
|
94
|
+
const input = this.querySelector('input');
|
|
95
|
+
const button = this.querySelector('button');
|
|
96
|
+
const msg = this.querySelector('[role="status"]');
|
|
97
|
+
const say = ({ tone, text }) => {
|
|
98
|
+
msg.hidden = false;
|
|
99
|
+
msg.dataset.tone = tone;
|
|
100
|
+
msg.textContent = text;
|
|
101
|
+
input.setAttribute('aria-invalid', tone === 'danger' ? 'true' : 'false');
|
|
102
|
+
};
|
|
103
|
+
form.addEventListener('submit', async (e) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
const email = cleanEmail(input.value);
|
|
106
|
+
if (!email) return say({ tone: 'danger', text: "That doesn't look like an email." });
|
|
107
|
+
button.disabled = true;
|
|
108
|
+
say({ tone: 'warning', text: 'Saving…' });
|
|
109
|
+
const res = await join({
|
|
110
|
+
email,
|
|
111
|
+
dn: this.getAttribute('dn') || location.hostname,
|
|
112
|
+
ref: refFrom(location.href),
|
|
113
|
+
api: this.getAttribute('api') || DEFAULT_API,
|
|
114
|
+
});
|
|
115
|
+
say(messageFor(res, email));
|
|
116
|
+
button.disabled = false;
|
|
117
|
+
if (res.ok) {
|
|
118
|
+
form.reset();
|
|
119
|
+
this.dispatchEvent(new CustomEvent('waitlist:joined', { bubbles: true, detail: { email, ...res } }));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* <waitlist-stats dn="name" [api] [days]>: a KPI and a per-day bar chart drawn with
|
|
127
|
+
* @profullstack/charts (window.pfcharts from charts.global.js, else the ESM bundle).
|
|
128
|
+
* Refreshes after a signup on the same page.
|
|
129
|
+
*/
|
|
130
|
+
export class WaitlistStats extends HTMLElementBase {
|
|
131
|
+
connectedCallback() {
|
|
132
|
+
if (this.dataset.ready) return;
|
|
133
|
+
this.dataset.ready = '1';
|
|
134
|
+
this.innerHTML = `<div class="stack waitlist-stats"><div data-kpi></div><div data-chart></div><p data-empty hidden></p></div>`;
|
|
135
|
+
this.refresh();
|
|
136
|
+
document.addEventListener('waitlist:joined', () => setTimeout(() => this.refresh(), 800));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async refresh() {
|
|
140
|
+
const dn = this.getAttribute('dn') || location.hostname;
|
|
141
|
+
const s = await stats({ dn, days: Number(this.getAttribute('days')) || 30, api: this.getAttribute('api') || DEFAULT_API });
|
|
142
|
+
const kpi = this.querySelector('[data-kpi]');
|
|
143
|
+
const chartEl = this.querySelector('[data-chart]');
|
|
144
|
+
const empty = this.querySelector('[data-empty]');
|
|
145
|
+
if (!s) {
|
|
146
|
+
kpi.textContent = '';
|
|
147
|
+
chartEl.hidden = true;
|
|
148
|
+
empty.hidden = false;
|
|
149
|
+
empty.textContent = 'The list is open. Be one of the first.';
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const charts = await loadCharts();
|
|
153
|
+
const series = s.days.map((d) => ({ day: d.day.slice(5), signups: d.n }));
|
|
154
|
+
if (!charts) {
|
|
155
|
+
kpi.textContent = `${s.total} on the waitlist`;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (this._kpi) this._kpi.update({ value: s.total, trend: s.days.map((d) => d.n) });
|
|
159
|
+
else this._kpi = charts(kpi).chart('stat', { value: s.total, trend: s.days.map((d) => d.n) }, { title: 'On the waitlist', table: false });
|
|
160
|
+
if (s.total === 0) {
|
|
161
|
+
empty.hidden = false;
|
|
162
|
+
empty.textContent = 'Nobody yet. Be the first.';
|
|
163
|
+
chartEl.hidden = true;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
empty.hidden = true;
|
|
167
|
+
chartEl.hidden = false;
|
|
168
|
+
const opts = { title: `Signups, last ${s.days.length} days`, height: 180, format: 'd', legend: false };
|
|
169
|
+
if (this._chart) this._chart.update(series, opts);
|
|
170
|
+
else this._chart = charts(chartEl).chart('bar', series, opts);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The charts `$` from charts.global.js (window.pfcharts) or the ESM bundle; null when neither loads. */
|
|
175
|
+
export function chartsFn(g) {
|
|
176
|
+
if (typeof g === 'function') return g;
|
|
177
|
+
if (g && typeof g.default === 'function') return g.default;
|
|
178
|
+
if (g && typeof g.$ === 'function') return g.$;
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function loadCharts() {
|
|
183
|
+
const fromGlobal = chartsFn(globalThis.pfcharts);
|
|
184
|
+
if (fromGlobal) return fromGlobal;
|
|
185
|
+
try {
|
|
186
|
+
return chartsFn(await import('@profullstack/charts/bundle'));
|
|
187
|
+
} catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function esc(s) {
|
|
193
|
+
return String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Background effects for the louder looks: matrix rain on a canvas. Static (one
|
|
198
|
+
* frame) under prefers-reduced-motion, so the look survives without the motion.
|
|
199
|
+
*/
|
|
200
|
+
export function startLookEffects(doc = globalThis.document) {
|
|
201
|
+
if (!doc || !doc.documentElement) return;
|
|
202
|
+
const look = doc.documentElement.dataset.look;
|
|
203
|
+
if (look !== 'matrix' || doc.querySelector('canvas[data-look-fx]')) return;
|
|
204
|
+
const c = doc.createElement('canvas');
|
|
205
|
+
c.setAttribute('data-look-fx', '');
|
|
206
|
+
c.setAttribute('aria-hidden', 'true');
|
|
207
|
+
doc.body.prepend(c);
|
|
208
|
+
const ctx = c.getContext('2d');
|
|
209
|
+
if (!ctx) return;
|
|
210
|
+
const glyphs = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<>/$#*+=:;{}[]|';
|
|
211
|
+
const size = 16;
|
|
212
|
+
let drops = [];
|
|
213
|
+
const resize = () => {
|
|
214
|
+
c.width = innerWidth;
|
|
215
|
+
c.height = innerHeight;
|
|
216
|
+
drops = Array.from({ length: Math.ceil(c.width / size) }, () => Math.random() * -50);
|
|
217
|
+
};
|
|
218
|
+
resize();
|
|
219
|
+
addEventListener('resize', resize);
|
|
220
|
+
const frame = () => {
|
|
221
|
+
ctx.fillStyle = 'rgba(0,0,0,0.08)';
|
|
222
|
+
ctx.fillRect(0, 0, c.width, c.height);
|
|
223
|
+
ctx.font = `${size}px monospace`;
|
|
224
|
+
drops.forEach((y, i) => {
|
|
225
|
+
ctx.fillStyle = Math.random() > 0.975 ? '#d7ffe0' : '#00ff41';
|
|
226
|
+
ctx.fillText(glyphs[(Math.random() * glyphs.length) | 0], i * size, y * size);
|
|
227
|
+
drops[i] = y * size > c.height && Math.random() > 0.975 ? 0 : y + 1;
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
231
|
+
for (let i = 0; i < 80; i++) frame();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
setInterval(frame, 55);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Register the elements (runs on import in a browser). */
|
|
238
|
+
export function defineWaitlist() {
|
|
239
|
+
if (!globalThis.customElements) return;
|
|
240
|
+
if (!customElements.get('waitlist-form')) customElements.define('waitlist-form', WaitlistForm);
|
|
241
|
+
if (!customElements.get('waitlist-stats')) customElements.define('waitlist-stats', WaitlistStats);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
defineWaitlist();
|
|
245
|
+
if (globalThis.document) {
|
|
246
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => startLookEffects());
|
|
247
|
+
else startLookEffects();
|
|
248
|
+
}
|
package/src/seo.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @profullstack/waitlist/seo: everything a search engine, a link unfurler or an
|
|
3
|
+
* answer engine reads about one waitlist site, derived from its spec.
|
|
4
|
+
*
|
|
5
|
+
* - head tags: title, description, canonical, robots, theme-color, icons,
|
|
6
|
+
* Open Graph and Twitter cards with a real 1200x630 PNG
|
|
7
|
+
* - JSON-LD: WebSite + Organization + WebPage + FAQPage (the same Q&As are on the page)
|
|
8
|
+
* - llms.txt, robots.txt (AI crawlers allowed), sitemap.xml, IndexNow key file
|
|
9
|
+
*
|
|
10
|
+
* Every derived value can be overridden per site in sites.json (see normalize in build.js).
|
|
11
|
+
*/
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
13
|
+
|
|
14
|
+
export function esc(s) {
|
|
15
|
+
return String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const OG_WIDTH = 1200;
|
|
19
|
+
export const OG_HEIGHT = 630;
|
|
20
|
+
|
|
21
|
+
const MONO = "'DejaVu Sans Mono', 'Liberation Mono', 'Courier New', monospace";
|
|
22
|
+
const SANS = "'DejaVu Sans', 'Liberation Sans', Arial, sans-serif";
|
|
23
|
+
|
|
24
|
+
/** Colors and type per look, mirrored from @profullstack/css/looks.css. */
|
|
25
|
+
export const PALETTES = {
|
|
26
|
+
neon: { bg: '#07020f', bg2: '#1b0830', ink: '#f2e9ff', muted: '#c7b4e8', title: '#ff2bd6', accent: '#33f6ff', onAccent: '#07020f', font: SANS, deco: 'glow' },
|
|
27
|
+
matrix: { bg: '#000000', bg2: '#001a06', ink: '#b6ffc8', muted: '#6fdc8c', title: '#00ff41', accent: '#00ff41', onAccent: '#000000', font: MONO, deco: 'rain' },
|
|
28
|
+
terminal: { bg: '#0b0b0b', bg2: '#1c1c1c', ink: '#d0d0d0', muted: '#9e9e9e', title: '#5fd700', accent: '#5fd700', onAccent: '#000000', font: MONO, deco: 'prompt' },
|
|
29
|
+
amber: { bg: '#0d0800', bg2: '#1e1200', ink: '#ffb000', muted: '#d99a2b', title: '#ffb000', accent: '#ffcc66', onAccent: '#1a0f00', font: MONO, deco: 'scan' },
|
|
30
|
+
synthwave: { bg: '#12002b', bg2: '#2b0057', ink: '#ffffff', muted: '#f3c6ff', title: '#ffd319', accent: '#ff2975', onAccent: '#ffffff', font: SANS, deco: 'grid' },
|
|
31
|
+
geocities: { bg: '#000033', bg2: '#000080', ink: '#ffffff', muted: '#00ff00', title: '#ffff00', accent: '#c0c0c0', onAccent: '#000000', font: "'Comic Neue', 'Comic Sans MS', " + SANS, deco: 'stars' },
|
|
32
|
+
vaporwave: { bg: '#ffd6f5', bg2: '#c2f0ff', ink: '#2d1b46', muted: '#5b3f7a', title: '#ff71ce', accent: '#b967ff', onAccent: '#ffffff', font: SANS, deco: 'shadow' },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function paletteFor(look) {
|
|
36
|
+
return PALETTES[look] || PALETTES.terminal;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Cut to `max` chars on a word boundary, adding an ellipsis when cut. */
|
|
40
|
+
export function clip(text, max) {
|
|
41
|
+
const t = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
42
|
+
if (t.length <= max) return t;
|
|
43
|
+
const cut = t.slice(0, max - 1);
|
|
44
|
+
const sp = cut.lastIndexOf(' ');
|
|
45
|
+
return (sp > max * 0.6 ? cut.slice(0, sp) : cut).replace(/[\s,.;:]+$/, '') + '…';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Greedy word wrap at ~`width` chars per line, at most `lines` lines. */
|
|
49
|
+
export function wrap(text, width, lines = 3) {
|
|
50
|
+
const words = String(text ?? '').split(/\s+/).filter(Boolean);
|
|
51
|
+
const out = [];
|
|
52
|
+
let cur = '';
|
|
53
|
+
for (const w of words) {
|
|
54
|
+
if (!cur) cur = w;
|
|
55
|
+
else if ((cur + ' ' + w).length <= width) cur += ' ' + w;
|
|
56
|
+
else { out.push(cur); cur = w; }
|
|
57
|
+
}
|
|
58
|
+
if (cur) out.push(cur);
|
|
59
|
+
if (out.length > lines) {
|
|
60
|
+
const kept = out.slice(0, lines);
|
|
61
|
+
kept[lines - 1] = clip(kept[lines - 1] + ' ' + out.slice(lines).join(' '), width);
|
|
62
|
+
return kept;
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function sentence(t) {
|
|
68
|
+
const s = String(t ?? '').trim();
|
|
69
|
+
return !s || /[.!?…]$/.test(s) ? s : s + '.';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Default derived SEO fields for a normalized spec `s` (overrides already applied by the caller). */
|
|
73
|
+
export function seoDefaults(s) {
|
|
74
|
+
const points = s.points || [];
|
|
75
|
+
const where = s.moshpit ? ` on the Moshpit` : '';
|
|
76
|
+
return {
|
|
77
|
+
seoTitle: clip(`${s.title}: ${s.tagline.replace(/[.!]$/, '')}`, 70),
|
|
78
|
+
description: clip(`${sentence(s.tagline)}${points.length ? ` ${sentence(points.slice(0, 2).join('. '))}` : ''} Join the waitlist.`, 160),
|
|
79
|
+
summary: `${s.title} is a new site${where} that is not open yet. ${sentence(s.tagline)} Join the waitlist to get one email when it opens.`,
|
|
80
|
+
imageAlt: `${s.title}: ${s.tagline}`,
|
|
81
|
+
faq: defaultFaq(s),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 3-5 Q&As written from the site's own name, tagline and points. */
|
|
86
|
+
export function defaultFaq(s) {
|
|
87
|
+
const points = s.points || [];
|
|
88
|
+
const faq = [{ q: `What is ${s.title}?`, a: `${sentence(s.tagline)} ${s.title} is not open yet: this page is its waitlist.` }];
|
|
89
|
+
if (points.length) faq.push({ q: `What will ${s.title} offer?`, a: sentence(points.map((p) => p.replace(/[.]$/, '')).join('; ')) });
|
|
90
|
+
faq.push({ q: `When does ${s.title} open, and how do I get in?`, a: `There is no public launch date yet. Enter your email on this page and confirm it; you get one email when ${s.title} opens, nothing else.` });
|
|
91
|
+
faq.push({ q: `Does joining the ${s.title} waitlist cost anything?`, a: `No. Joining is free and needs only an email address. Each confirmed address counts once, and the live count of who is waiting is shown on the page.` });
|
|
92
|
+
if (s.moshpit) {
|
|
93
|
+
faq.push({ q: `Where is ${s.title} on the web?`, a: `${s.name} is a Moshpit name: it opens at https://${s.name} in a Moshpit-aware browser or resolver, and at https://${s.host}/ on the regular web through the pit.world relay.` });
|
|
94
|
+
}
|
|
95
|
+
return faq.slice(0, 5);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The <head> tags for SEO and social cards. `s` is a normalized spec with seo fields. */
|
|
99
|
+
export function headTags(s, { noindex = false } = {}) {
|
|
100
|
+
const p = paletteFor(s.look);
|
|
101
|
+
const t = [
|
|
102
|
+
`<title>${esc(s.seoTitle)}</title>`,
|
|
103
|
+
`<meta name="description" content="${esc(s.description)}">`,
|
|
104
|
+
`<meta name="robots" content="${noindex ? 'noindex, follow' : 'index, follow, max-image-preview:large, max-snippet:-1'}">`,
|
|
105
|
+
`<link rel="canonical" href="${esc(s.url)}">`,
|
|
106
|
+
s.moshpit && s.nativeUrl !== s.url ? `<link rel="alternate" href="${esc(s.nativeUrl)}" title="${esc(s.name)} on the Moshpit">` : '',
|
|
107
|
+
`<meta name="theme-color" content="${esc(s.themeColor || p.bg)}">`,
|
|
108
|
+
`<meta name="color-scheme" content="${s.look === 'vaporwave' ? 'light' : 'dark'}">`,
|
|
109
|
+
`<link rel="icon" href="assets/icon.svg" type="image/svg+xml">`,
|
|
110
|
+
`<link rel="icon" href="assets/icon-192.png" type="image/png" sizes="192x192">`,
|
|
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">`,
|
|
113
|
+
`<meta property="og:type" content="website">`,
|
|
114
|
+
`<meta property="og:site_name" content="${esc(s.siteName)}">`,
|
|
115
|
+
`<meta property="og:locale" content="${esc(s.locale)}">`,
|
|
116
|
+
`<meta property="og:title" content="${esc(s.seoTitle)}">`,
|
|
117
|
+
`<meta property="og:description" content="${esc(s.description)}">`,
|
|
118
|
+
`<meta property="og:url" content="${esc(s.url)}">`,
|
|
119
|
+
`<meta property="og:image" content="${esc(s.image)}">`,
|
|
120
|
+
s.image.startsWith('https:') ? `<meta property="og:image:secure_url" content="${esc(s.image)}">` : '',
|
|
121
|
+
`<meta property="og:image:type" content="image/png">`,
|
|
122
|
+
`<meta property="og:image:width" content="${OG_WIDTH}">`,
|
|
123
|
+
`<meta property="og:image:height" content="${OG_HEIGHT}">`,
|
|
124
|
+
`<meta property="og:image:alt" content="${esc(s.imageAlt)}">`,
|
|
125
|
+
`<meta name="twitter:card" content="summary_large_image">`,
|
|
126
|
+
`<meta name="twitter:title" content="${esc(s.seoTitle)}">`,
|
|
127
|
+
`<meta name="twitter:description" content="${esc(s.description)}">`,
|
|
128
|
+
`<meta name="twitter:image" content="${esc(s.image)}">`,
|
|
129
|
+
`<meta name="twitter:image:alt" content="${esc(s.imageAlt)}">`,
|
|
130
|
+
s.twitter ? `<meta name="twitter:site" content="${esc(s.twitter)}">` : '',
|
|
131
|
+
s.keywords?.length ? `<meta name="keywords" content="${esc(s.keywords.join(', '))}">` : '',
|
|
132
|
+
];
|
|
133
|
+
return t.filter(Boolean).join('\n');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** JSON-LD @graph: WebSite, Organization, WebPage and FAQPage (plus any `schema` extras from the spec). */
|
|
137
|
+
export function jsonLd(s) {
|
|
138
|
+
const id = (frag) => `${s.url}#${frag}`;
|
|
139
|
+
const graph = [
|
|
140
|
+
{ '@type': 'WebSite', '@id': id('website'), name: s.title, alternateName: s.moshpit ? [s.name, s.host] : undefined, url: s.url, description: s.description, inLanguage: s.lang, publisher: { '@id': id('org') } },
|
|
141
|
+
{ '@type': 'Organization', '@id': id('org'), name: s.title, url: s.url, logo: { '@type': 'ImageObject', url: `${s.url}assets/icon-192.png`, width: 192, height: 192 }, sameAs: s.sameAs?.length ? s.sameAs : undefined, parentOrganization: s.publisher ? { '@type': 'Organization', name: s.publisher.name, url: s.publisher.url } : undefined },
|
|
142
|
+
{ '@type': 'WebPage', '@id': id('page'), url: s.url, name: s.seoTitle, description: s.summary, inLanguage: s.lang, isPartOf: { '@id': id('website') }, about: { '@id': id('org') }, primaryImageOfPage: { '@type': 'ImageObject', url: s.image, width: OG_WIDTH, height: OG_HEIGHT }, potentialAction: { '@type': 'JoinAction', name: s.button, target: s.url } },
|
|
143
|
+
{ '@type': 'FAQPage', '@id': id('faq'), mainEntity: s.faq.map((f) => ({ '@type': 'Question', name: f.q, acceptedAnswer: { '@type': 'Answer', text: f.a } })) },
|
|
144
|
+
...(Array.isArray(s.schema) ? s.schema : s.schema ? [s.schema] : []),
|
|
145
|
+
];
|
|
146
|
+
return JSON.stringify({ '@context': 'https://schema.org', '@graph': graph });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Inline-safe JSON-LD script tag (no `</script>` breakout). */
|
|
150
|
+
export function jsonLdTag(s) {
|
|
151
|
+
return `<script type="application/ld+json">${jsonLd(s).replace(/</g, '\\u003c')}</script>`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The visible FAQ section: same questions as the FAQPage JSON-LD. */
|
|
155
|
+
export function faqHtml(s) {
|
|
156
|
+
if (!s.faq.length) return '';
|
|
157
|
+
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></details>`).join('\n ')}
|
|
159
|
+
</section>`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** llms.txt (llmstxt.org): what it is, who it's for, status, how to join. */
|
|
163
|
+
export function llmsTxt(s) {
|
|
164
|
+
const lines = [
|
|
165
|
+
`# ${s.title}`,
|
|
166
|
+
'',
|
|
167
|
+
`> ${s.summary}`,
|
|
168
|
+
'',
|
|
169
|
+
`- Status: waitlist (not launched yet)`,
|
|
170
|
+
`- Site: ${s.url}`,
|
|
171
|
+
s.moshpit ? `- Moshpit name: https://${s.name}` : '',
|
|
172
|
+
s.audience ? `- Who it is for: ${s.audience}` : '',
|
|
173
|
+
`- How to join: enter an email at ${s.url} and confirm it, or POST {"email","dn":"${s.dn}"} to ${s.api}/api/waitlist`,
|
|
174
|
+
`- Waitlist count: ${s.api}/api/waitlist/stats?dn=${encodeURIComponent(s.dn)}`,
|
|
175
|
+
'',
|
|
176
|
+
].filter((l, i, a) => l !== '' || a[i - 1] !== '');
|
|
177
|
+
if (s.points.length) lines.push('## What is coming', '', ...s.points.map((p) => `- ${p}`), '');
|
|
178
|
+
lines.push('## Questions', '');
|
|
179
|
+
for (const f of s.faq) lines.push(`### ${f.q}`, '', f.a, '');
|
|
180
|
+
lines.push('## Links', '', `- [Home](${s.url}): the waitlist page`, `- [Sitemap](${s.url}sitemap.xml)`);
|
|
181
|
+
if (s.moshpit) lines.push(`- [pit.world directory](https://pit.world/directory): other Moshpit names`);
|
|
182
|
+
return lines.join('\n') + '\n';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** AI and answer-engine crawlers we welcome by name (plus everyone else via *). */
|
|
186
|
+
export const AI_CRAWLERS = [
|
|
187
|
+
'GPTBot', 'OAI-SearchBot', 'ChatGPT-User', 'ClaudeBot', 'Claude-SearchBot', 'Claude-User', 'anthropic-ai',
|
|
188
|
+
'PerplexityBot', 'Perplexity-User', 'Google-Extended', 'Applebot', 'Applebot-Extended', 'Bingbot', 'DuckDuckBot',
|
|
189
|
+
'DuckAssistBot', 'CCBot', 'Meta-ExternalAgent', 'Amazonbot', 'cohere-ai', 'MistralAI-User', 'YouBot', 'PhindBot',
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
export function robotsTxt(s) {
|
|
193
|
+
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`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function sitemapXml(s) {
|
|
197
|
+
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`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** A stable IndexNow key for a name (hex, 32 chars); override with spec.indexnowKey. */
|
|
201
|
+
export function indexNowKey(name) {
|
|
202
|
+
return createHash('sha256').update(`waitlist-indexnow:${name}`).digest('hex').slice(0, 32);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Ping IndexNow (Bing, Yandex, Seznam, Naver share it) for each built site. Never throws. */
|
|
206
|
+
export async function pingIndexNow(sites, { fetchImpl = globalThis.fetch, endpoint = 'https://api.indexnow.org/indexnow' } = {}) {
|
|
207
|
+
const results = [];
|
|
208
|
+
for (const s of sites) {
|
|
209
|
+
const host = new URL(s.url).host;
|
|
210
|
+
try {
|
|
211
|
+
const res = await fetchImpl(endpoint, {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
214
|
+
body: JSON.stringify({ host, key: s.indexnowKey, keyLocation: `${s.url}${s.indexnowKey}.txt`, urlList: [s.url, `${s.url}llms.txt`] }),
|
|
215
|
+
});
|
|
216
|
+
results.push({ host, status: res.status });
|
|
217
|
+
} catch (err) {
|
|
218
|
+
results.push({ host, status: 0, error: err.message });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return results;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ---------- images ----------
|
|
225
|
+
|
|
226
|
+
function decoration(p, w, h, name) {
|
|
227
|
+
let h32 = 0;
|
|
228
|
+
for (const ch of name) h32 = (h32 * 31 + ch.charCodeAt(0)) >>> 0;
|
|
229
|
+
const rnd = () => ((h32 = (h32 * 1103515245 + 12345) >>> 0) / 2 ** 32);
|
|
230
|
+
switch (p.deco) {
|
|
231
|
+
case 'grid': {
|
|
232
|
+
let g = `<rect y="${h * 0.62}" width="${w}" height="${h * 0.38}" fill="#12002b"/>`;
|
|
233
|
+
for (let i = 0; i <= 8; i++) { const y = h * 0.62 + (h * 0.38) * (i / 8) ** 2; g += `<line x1="0" y1="${y.toFixed(1)}" x2="${w}" y2="${y.toFixed(1)}" stroke="#ff2975" stroke-opacity=".55" stroke-width="2"/>`; }
|
|
234
|
+
for (let i = -12; i <= 12; i++) g += `<line x1="${w / 2 + i * 40}" y1="${h * 0.62}" x2="${w / 2 + i * 220}" y2="${h}" stroke="#ff2975" stroke-opacity=".55" stroke-width="2"/>`;
|
|
235
|
+
return `<circle cx="${w * 0.8}" cy="${h * 0.62}" r="150" fill="url(#sun)"/>${g}`;
|
|
236
|
+
}
|
|
237
|
+
case 'stars': {
|
|
238
|
+
let g = '';
|
|
239
|
+
for (let i = 0; i < 90; i++) g += `<circle cx="${(rnd() * w).toFixed(0)}" cy="${(rnd() * h).toFixed(0)}" r="${(1 + rnd() * 2).toFixed(1)}" fill="${rnd() > 0.5 ? '#ffffff' : '#ffff66'}"/>`;
|
|
240
|
+
return g + `<rect x="10" y="10" width="${w - 20}" height="${h - 20}" fill="none" stroke="#c0c0c0" stroke-width="8"/>`;
|
|
241
|
+
}
|
|
242
|
+
case 'rain': {
|
|
243
|
+
let g = '';
|
|
244
|
+
for (let x = 20; x < w; x += 46) {
|
|
245
|
+
const len = 4 + Math.floor(rnd() * 10), y0 = Math.floor(rnd() * 12);
|
|
246
|
+
for (let j = 0; j < len; j++) g += `<text x="${x}" y="${(y0 + j) * 34}" font-family="${MONO}" font-size="26" fill="#00ff41" fill-opacity="${(0.08 + 0.25 * (j / len)).toFixed(2)}">${rnd() > 0.5 ? '1' : '0'}</text>`;
|
|
247
|
+
}
|
|
248
|
+
return g;
|
|
249
|
+
}
|
|
250
|
+
case 'scan': {
|
|
251
|
+
let g = '';
|
|
252
|
+
for (let y = 0; y < h; y += 6) g += `<rect y="${y}" width="${w}" height="2" fill="#000" fill-opacity=".35"/>`;
|
|
253
|
+
return g;
|
|
254
|
+
}
|
|
255
|
+
case 'prompt':
|
|
256
|
+
return `<rect x="40" y="36" width="${w - 80}" height="44" rx="8" fill="#1c1c1c"/><circle cx="70" cy="58" r="8" fill="#ff5f56"/><circle cx="96" cy="58" r="8" fill="#ffbd2e"/><circle cx="122" cy="58" r="8" fill="#27c93f"/>`;
|
|
257
|
+
case 'glow':
|
|
258
|
+
return `<rect x="24" y="24" width="${w - 48}" height="${h - 48}" rx="28" fill="none" stroke="#ff2bd6" stroke-width="4" filter="url(#glow)"/>`;
|
|
259
|
+
case 'shadow':
|
|
260
|
+
return `<rect x="56" y="56" width="${w - 112}" height="${h - 112}" fill="#2d1b46"/><rect x="40" y="40" width="${w - 112}" height="${h - 112}" fill="#ffffff" fill-opacity=".85" stroke="#2d1b46" stroke-width="4"/>`;
|
|
261
|
+
default:
|
|
262
|
+
return '';
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The 1200x630 Open Graph card as SVG, in the site's look. */
|
|
267
|
+
export function ogSvg(s) {
|
|
268
|
+
const p = paletteFor(s.look);
|
|
269
|
+
const W = OG_WIDTH, H = OG_HEIGHT, X = 80;
|
|
270
|
+
const mono = p.font === MONO;
|
|
271
|
+
const titleText = s.look === 'terminal' ? `$ ${s.title}_` : s.look === 'vaporwave' ? s.title.toUpperCase() : s.title;
|
|
272
|
+
const charW = s.look === "vaporwave" ? 0.8 : mono ? 0.62 : 0.66;
|
|
273
|
+
const titleSize = Math.max(56, Math.min(124, Math.floor((W - 2 * X) / (titleText.length * charW))));
|
|
274
|
+
const tagSize = 42;
|
|
275
|
+
const tagLines = wrap(s.tagline, Math.floor((W - 2 * X) / (tagSize * (mono ? 0.61 : 0.53))), 3);
|
|
276
|
+
const titleY = 268;
|
|
277
|
+
const tagY0 = titleY + 40 + tagSize;
|
|
278
|
+
const shadow = s.look === 'geocities' ? `<text x="${X + 5}" y="${titleY + 5}" font-family="${p.font}" font-size="${titleSize}" font-weight="700" fill="#ff0000">${esc(titleText)}</text>`
|
|
279
|
+
: s.look === 'vaporwave' ? `<text x="${X + 5}" y="${titleY + 5}" font-family="${p.font}" font-size="${titleSize}" font-weight="700" fill="#01cdfe">${esc(titleText)}</text>` : '';
|
|
280
|
+
const glow = ['neon', 'matrix', 'amber', 'synthwave'].includes(s.look) ? ' filter="url(#glow)"' : '';
|
|
281
|
+
const kicker = esc(s.kicker.toUpperCase());
|
|
282
|
+
const kickerW = Math.min(W - 2 * X, kicker.length * 17 + 48);
|
|
283
|
+
const cta = esc(s.button);
|
|
284
|
+
const ctaW = cta.length * 17 + 56;
|
|
285
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">
|
|
286
|
+
<defs>
|
|
287
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${p.bg}"/><stop offset="1" stop-color="${p.bg2}"/></linearGradient>
|
|
288
|
+
<radialGradient id="sun"><stop offset="0" stop-color="#ffd319"/><stop offset="1" stop-color="#ff2975"/></radialGradient>
|
|
289
|
+
<filter id="glow" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="6" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge></filter>
|
|
290
|
+
</defs>
|
|
291
|
+
<rect width="${W}" height="${H}" fill="url(#bg)"/>
|
|
292
|
+
${decoration(p, W, H, s.name)}
|
|
293
|
+
<rect x="${X}" y="84" width="${kickerW}" height="44" rx="${s.look === 'geocities' || s.look === 'vaporwave' ? 0 : 22}" fill="${p.accent}" fill-opacity=".16" stroke="${p.accent}" stroke-width="2"/>
|
|
294
|
+
<text x="${X + 22}" y="114" font-family="${MONO}" font-size="22" letter-spacing="2" fill="${p.accent}">${kicker}</text>
|
|
295
|
+
${shadow}<text x="${X}" y="${titleY}" font-family="${p.font}" font-size="${titleSize}" font-weight="700" fill="${p.title}"${glow}>${esc(titleText)}</text>
|
|
296
|
+
${tagLines.map((l, i) => `<text x="${X}" y="${tagY0 + i * (tagSize + 14)}" font-family="${p.font}" font-size="${tagSize}" fill="${p.ink}">${esc(l)}</text>`).join('\n')}
|
|
297
|
+
<rect x="${X}" y="${H - 122}" width="${ctaW}" height="62" rx="${s.look === 'geocities' || s.look === 'vaporwave' ? 0 : 12}" fill="${p.accent}"/>
|
|
298
|
+
<text x="${X + 28}" y="${H - 81}" font-family="${SANS}" font-size="28" font-weight="700" fill="${p.onAccent}">${cta}</text>
|
|
299
|
+
<text x="${W - X}" y="${H - 80}" text-anchor="end" font-family="${MONO}" font-size="26" fill="${p.muted}">${esc(s.moshpit ? s.name : new URL(s.url).host)}</text>
|
|
300
|
+
</svg>
|
|
301
|
+
`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Square icon SVG in the look's colors. */
|
|
305
|
+
export function iconSvg(s) {
|
|
306
|
+
const p = paletteFor(s.look);
|
|
307
|
+
const ch = esc((s.name.match(/[a-z0-9]/i) || ['?'])[0].toUpperCase());
|
|
308
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="${p.bg}"/><rect x="2" y="2" width="60" height="60" rx="12" fill="none" stroke="${p.accent}" stroke-width="3"/><text x="32" y="45" text-anchor="middle" font-family="${MONO}" font-size="36" font-weight="700" fill="${p.title}">${ch}</text></svg>\n`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
let resvg;
|
|
312
|
+
/** SVG -> PNG with @resvg/resvg-js (prebuilt native, no system deps). `width` scales the output. */
|
|
313
|
+
export async function svgToPng(svg, { width, fontFiles = [] } = {}) {
|
|
314
|
+
resvg ??= (await import('@resvg/resvg-js')).Resvg;
|
|
315
|
+
const r = new resvg(svg, {
|
|
316
|
+
fitTo: width ? { mode: 'width', value: width } : { mode: 'original' },
|
|
317
|
+
font: { loadSystemFonts: true, fontFiles, defaultFontFamily: 'DejaVu Sans' },
|
|
318
|
+
background: 'rgba(0,0,0,0)',
|
|
319
|
+
});
|
|
320
|
+
return Buffer.from(r.render().asPng());
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Width and height from a PNG's IHDR chunk. */
|
|
324
|
+
export function pngSize(buf) {
|
|
325
|
+
if (buf.length < 24 || buf.readUInt32BE(0) !== 0x89504e47 || buf.toString('latin1', 12, 16) !== 'IHDR') return null;
|
|
326
|
+
return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };
|
|
327
|
+
}
|
package/src/waitlist.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* @profullstack/waitlist: page layer on top of @profullstack/css tokens (--pf-*). */
|
|
2
|
+
.waitlist-page { min-height: 100dvh; display: flex; flex-direction: column; }
|
|
3
|
+
.waitlist-page > main { flex: 1; }
|
|
4
|
+
.waitlist-hero { padding-block: clamp(2.5rem, 8vw, 6rem) 2rem; }
|
|
5
|
+
.waitlist-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1.05; letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
|
|
6
|
+
.waitlist-hero .waitlist-tagline { font-size: clamp(1.1rem, 2.4vw, 1.45rem); color: var(--pf-color-muted, inherit); max-width: 40rem; }
|
|
7
|
+
.waitlist-kicker { font-family: var(--pf-font-mono, ui-monospace, monospace); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; }
|
|
8
|
+
.waitlist-form .field-group { max-width: 34rem; }
|
|
9
|
+
.waitlist-form .field-group input { flex: 1; min-width: 0; }
|
|
10
|
+
.waitlist-points li { margin-block: 0.35rem; }
|
|
11
|
+
.waitlist-stats [data-empty] { color: var(--pf-color-muted, inherit); margin: 0; }
|
|
12
|
+
.waitlist-meta { font-size: 0.9rem; color: var(--pf-color-muted, inherit); }
|
|
13
|
+
.waitlist-answer { max-width: 40rem; margin: 0; }
|
|
14
|
+
.waitlist-faq { margin-block: 1.5rem; }
|
|
15
|
+
.waitlist-faq details { border-block-start: 1px solid var(--pf-color-border, currentColor); padding-block: 0.6rem; }
|
|
16
|
+
.waitlist-faq summary { cursor: pointer; font-weight: 600; }
|
|
17
|
+
.waitlist-faq details p { margin-block: 0.5rem 0; }
|
|
18
|
+
|
|
19
|
+
/* Looks (neon, matrix, terminal, amber, synthwave, geocities, vaporwave) come from
|
|
20
|
+
@profullstack/css/looks: <html data-look="...">. Only page tweaks live here. */
|
|
21
|
+
[data-look] .waitlist-hero h1 { font-size: clamp(2.2rem, 7vw, 4.5rem); }
|