feat: plugin pages, ESM-only npm, and a home that sells the listing #2

Merged
chrnx merged 11 commits from feature/plugin-pages into develop 2026-09-24 15:30:02 +00:00
21 changed files with 1199 additions and 202 deletions

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
# Listing a plugin
## What counts as a green-tea plugin
A factory that returns `{ name, mount }`. It imports `@green-tea/core` as types only, with core in
`devDependencies`, so installing the plugin never pulls in a second copy of core. It needs
`@green-tea/core@26.9.0-beta.2` or newer. That is the release where plugins took this shape and
`app.boot()` became public.
## Where to publish it
JSR is what we recommend. It records which runtimes a package supports, and the listing shows
that on every card.
npm works too, as long as the package is ESM only: `"type": "module"`, no `require` condition, and
no `.cjs` file in `main` or `exports`. Dual ESM/CJS packages are turned away. green-tea is ESM from
end to end, and a `require` path is the first thing to break when the Node version floor moves.
## Add the entry
Add one file, `src/content/plugins/<name>.yaml`:
```yaml
jsr: "@your-scope/green-tea-your-plugin" # or npm: green-tea-your-plugin
repo: https://github.com/you/green-tea-your-plugin
description: "One sentence, 20 to 200 characters."
```
Names follow one pattern per registry: `green-tea-<x>` or `@scope/green-tea-<x>` on npm,
`@scope/<x>` on JSR. There is no version field and no runtimes field. The listing reads both from
the registry, so your entry can't go stale.
## What gets checked
The build checks two things on its own: the package exists on the registry you named, and an npm
package is ESM only. A package that fails either one is not listed.
A person checks the rest. The package has to be a factory returning `{ name, mount }` and keep
core as a type-only dependency. Its README has to cover all four runtimes (Node, Deno, Bun,
workerd) and give a reason next to each one it doesn't support.
## When it goes live
Merged entries go out with the next Friday cut.
+173 -1
View File
@@ -9,7 +9,9 @@
"version": "26.9.0",
"dependencies": {
"@astrojs/sitemap": "^3.7.3",
"astro": "^7.1.6"
"astro": "^7.1.6",
"js-yaml": "^4.3.2",
"sanitize-html": "^2.17.7"
},
"engines": {
"node": ">=22.12.0"
@@ -2298,6 +2300,21 @@
"integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==",
"license": "CC0-1.0"
},
"node_modules/dayjs": {
"version": "1.11.23",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz",
"integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==",
"license": "MIT"
},
"node_modules/deepmerge": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/defu": {
"version": "6.1.7",
"resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz",
@@ -2479,6 +2496,18 @@
"@esbuild/win32-x64": "0.28.2"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eventemitter3": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz",
@@ -2675,6 +2704,107 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/htmlparser2": {
"version": "12.0.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-12.0.0.tgz",
"integrity": "sha512-Tz7u1i95/g2x2jz81+x0FBVhBhY5aRTvD3tXXdFaljuNdzDLJ8UGNRrTcj2cgQvAg3iW/h77Fz15nLW0L0CrZw==",
"funding": [
"https://github.com/fb55/htmlparser2?sponsor=1",
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "MIT",
"dependencies": {
"domelementtype": "^3.0.0",
"domhandler": "^6.0.0",
"domutils": "^4.0.2",
"entities": "^8.0.0"
},
"engines": {
"node": ">=20.19.0"
}
},
"node_modules/htmlparser2/node_modules/dom-serializer": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-3.1.1.tgz",
"integrity": "sha512-4MEa38/QexBob6gFNwu+EGdWvhJ1OKuNwdYY3Y3NyeWDQfnGeDYQUDfIRzWu5B5gsv03so2Uxd28YC6zrsx3Lw==",
"license": "MIT",
"dependencies": {
"domelementtype": "^3.0.0",
"domhandler": "^6.0.0",
"entities": "^8.0.0"
},
"engines": {
"node": ">=20.19.0"
},
"funding": {
"type": "github",
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
}
},
"node_modules/htmlparser2/node_modules/domelementtype": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-3.0.0.tgz",
"integrity": "sha512-umCQid3jKbDmVjx8jGaW7uUykm4DEUeyV21hPxNMo2nV955DhUThwqyOIDtreepP31hl84X7G5U9ZfsWvIB3Pg==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "BSD-2-Clause",
"engines": {
"node": ">=20.19.0"
}
},
"node_modules/htmlparser2/node_modules/domhandler": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-6.0.1.tgz",
"integrity": "sha512-gYzvtM72ZtxQO0T048kd6HWSbbGCNOUwcnfQ01cqIJ4X2IYKFFHZ5mKvrQETcFXxsRObZulDaKmy//R7TPtsBg==",
"license": "BSD-2-Clause",
"dependencies": {
"domelementtype": "^3.0.0"
},
"engines": {
"node": ">=20.19.0"
},
"funding": {
"type": "github",
"url": "https://github.com/fb55/domhandler?sponsor=1"
}
},
"node_modules/htmlparser2/node_modules/domutils": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-4.0.2.tgz",
"integrity": "sha512-qI4JLRKnSzqFqr7hAlS5xQDusBCjKSEG4t4+7aNrIQMHBcsC2TGEhuyABJdYkgSewL57PNLYEiibY2iPKhKpaA==",
"license": "BSD-2-Clause",
"dependencies": {
"dom-serializer": "^3.0.0",
"domelementtype": "^3.0.0",
"domhandler": "^6.0.0"
},
"engines": {
"node": ">=20.19.0"
},
"funding": {
"type": "github",
"url": "https://github.com/fb55/domutils?sponsor=1"
}
},
"node_modules/htmlparser2/node_modules/entities": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz",
"integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=20.19.0"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/http-cache-semantics": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
@@ -2717,6 +2847,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-plain-object": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.1.0.tgz",
"integrity": "sha512-bUi/yjmtKYcRVUtWRGr0UA6xEFh2I6zWUwMrUXB3s7bmYCaZ8a+0ZsTRkrawh/mzlSD1Y0Ph8bp/U+TvBpWDNw==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/js-yaml": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
@@ -2745,6 +2884,15 @@
"integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==",
"license": "MIT"
},
"node_modules/launder": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/launder/-/launder-1.7.1.tgz",
"integrity": "sha512-mU6WRz5EusL9ZZuiZ5SO4Y6C0P9PAUR9iwdb6bzj4KDihm28DiHFw+/yk9DBH4f+Pv1wuzQ4e2jV3oQ7mkIqvw==",
"license": "MIT",
"dependencies": {
"dayjs": "^1.11.7"
}
},
"node_modules/lightningcss": {
"version": "1.33.0",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
@@ -3317,6 +3465,12 @@
"integrity": "sha512-yQA4H19AmPEoMUeavPMDIe1higySl/gH/yaQrkT/s07Qp+7pp2hYz30N3z2l5BkjVkF9Ow6o0wjJamm2y7Sn0A==",
"license": "MIT"
},
"node_modules/parse-srcset": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz",
"integrity": "sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==",
"license": "MIT"
},
"node_modules/piccolore": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz",
@@ -3497,6 +3651,24 @@
"@rolldown/binding-win32-x64-msvc": "1.2.9"
}
},
"node_modules/sanitize-html": {
"version": "2.17.7",
"resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.17.7.tgz",
"integrity": "sha512-PGtEkc9cbnedU3s9TmzDbpsZ8w086g/0Q8k8/oIO1NLNU3i5k9yn835CrjJSajp1KMmkisbO1qPXxNKO3welAg==",
"license": "MIT",
"dependencies": {
"deepmerge": "^4.2.2",
"escape-string-regexp": "^4.0.0",
"htmlparser2": "^12.0.0",
"is-plain-object": "^5.0.0",
"launder": "^1.7.1",
"parse-srcset": "^1.0.2",
"postcss": "^8.3.11"
},
"engines": {
"node": ">=22.12.0"
}
},
"node_modules/satteri": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/satteri/-/satteri-0.10.5.tgz",
+4 -2
View File
@@ -10,12 +10,14 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"test": "node scripts/deploy.mjs --self-test",
"test": "node scripts/deploy.mjs --self-test && node --test scripts/registry.test.mjs",
"deploy": "npm run build && node scripts/deploy.mjs",
"astro": "astro"
},
"dependencies": {
"@astrojs/sitemap": "^3.7.3",
"astro": "^7.1.6"
"astro": "^7.1.6",
"js-yaml": "^4.3.2",
"sanitize-html": "^2.17.7"
}
}
+43
View File
@@ -0,0 +1,43 @@
// The `plugins` collection's loader. It replaces `glob` because `renderMarkdown` only exists inside
// a loader, and the README has to be rendered with the site's own pipeline (shiki included).
// Wrapping `glob` was tried on 2026-09-24 and the added fields did not persist; a standalone
// loader did.
import { readdirSync, readFileSync } from 'node:fs';
import yaml from 'js-yaml';
import { readEntry } from './registry.mjs';
import { cleanReadme } from './readme.mjs';
/** `entrySchema` validates one yaml file; it is the contributor-facing contract. */
export function pluginsLoader(entrySchema) {
return {
name: 'plugins',
// ponytail: no file watcher — after editing a yaml in `npm run dev`, restart it. Add a watcher
// if contributors start previewing entries locally.
load: async ({ store, renderMarkdown, config }) => {
store.clear();
const dir = new URL('src/content/plugins/', config.root);
const files = readdirSync(dir).filter((file) => file.endsWith('.yaml') && !file.startsWith('_'));
await Promise.all(
files.map(async (file) => {
const parsed = entrySchema.safeParse(yaml.load(readFileSync(new URL(file, dir), 'utf8')));
if (!parsed.success) {
throw new Error(`src/content/plugins/${file}: ${parsed.error.issues.map((i) => i.message).join('; ')}`);
}
const live = await readEntry(parsed.data);
if (!live) return;
const { readme, readmeBase, ...data } = live;
const rendered = await renderMarkdown(readme);
store.set({
id: file.replace(/\.yaml$/, ''),
data: { ...parsed.data, ...data },
rendered: { ...rendered, html: cleanReadme(rendered.html, readmeBase) },
});
}),
);
},
};
}
+71
View File
@@ -0,0 +1,71 @@
// A plugin's README is somebody else's HTML. Review reads the yaml once; the README can change on
// any later publish and reach the site at the next Friday cut. So it is cleaned against a closed
// allowlist every build, and never trusted because the entry was.
import sanitizeHtml from 'sanitize-html';
const HEX = /^#[0-9a-f]{3,8}$/i;
/** Relative URLs resolve against the published package; anchors and absolute URLs stay. */
function absolute(url, base) {
if (!url || url.startsWith('#')) return url;
try {
return new URL(url, base).href;
} catch {
return url;
}
}
/** Only touch the attribute when it is there — setting it to `undefined` renders a bare `href`. */
function rebase(attribs, key, base) {
return key in attribs ? { ...attribs, [key]: absolute(attribs[key], base) } : attribs;
}
export function cleanReadme(html, base) {
return sanitizeHtml(html, {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2', 'details', 'summary', 'picture', 'source']),
allowedAttributes: {
'*': ['id', 'align'],
a: ['href', 'title'],
img: ['src', 'alt', 'title', 'width', 'height'],
source: ['srcset', 'media'],
pre: ['class', 'style', 'tabindex', 'data-language'],
span: ['class', 'style'],
code: ['class'],
},
// Only what shiki writes. Anything else (position, inset, z-index…) would let a README draw
// over the page around it.
allowedStyles: {
'*': { color: [HEX], 'background-color': [HEX], 'overflow-x': [/^auto$/] },
},
// Only the classes shiki writes, spelled out. A README that could use any class could borrow the
// site's own (`card__link::after` is a full-page overlay) and draw over the page that way.
// `github-dark` is Astro's default theme; change it here if astro.config.mjs picks another.
allowedClasses: {
pre: ['astro-code', 'github-dark'],
code: [/^language-[a-z0-9+#-]+$/],
span: ['line'],
},
allowedSchemes: ['http', 'https', 'mailto'],
transformTags: {
a: (tagName, attribs) => ({ tagName, attribs: rebase(attribs, 'href', base) }),
img: (tagName, attribs) => ({ tagName, attribs: rebase(attribs, 'src', base) }),
// `srcset` is a comma-separated list of "url descriptor" pairs; only the url moves.
source: (tagName, attribs) =>
'srcset' in attribs
? {
tagName,
attribs: {
...attribs,
srcset: attribs.srcset
.split(',')
.map((candidate) => {
const [url, ...descriptor] = candidate.trim().split(/\s+/);
return [absolute(url, base), ...descriptor].join(' ');
})
.join(', '),
},
}
: { tagName, attribs },
},
});
}
+73 -7
View File
@@ -48,7 +48,41 @@ function compare(a, b) {
* `@green-tea/core`, which has two published versions and `"latest": null`.
*/
export function newestVersion(versions) {
return [...versions].sort(compare).pop();
return byNewest(versions)[0];
}
/** Versions sorted newest first. */
export function byNewest(versions) {
return [...versions].sort(compare).reverse();
}
/**
* ESM only, with no CJS way in at all — dual packages included, because green-tea is ESM end to
* end and a `require` path is what breaks first when the Node floor moves.
*/
export function isEsmOnly({ type, main, exports }) {
if (type !== 'module') return false;
const cjs = (node, key) => {
if (key === 'require') return true;
if (typeof node === 'string') return node.endsWith('.cjs');
if (node && typeof node === 'object') return Object.entries(node).some(([k, v]) => cjs(v, k));
return false;
};
return !cjs(main) && !cjs(exports);
}
/** JSR's version list minus yanked ones — the registry hides those, so the listing must too. */
export function publishedVersions(items) {
return items.filter((item) => !item.yanked).map((item) => item.version);
}
/** npm stores this literal string when a package ships no README. */
export function npmReadme(packument) {
const readme = packument.readme ?? '';
return readme.startsWith('ERROR: No README data found') ? '' : readme;
}
async function getJson(url, what) {
@@ -58,6 +92,13 @@ async function getJson(url, what) {
return response.json();
}
async function getText(url, what) {
const response = await fetch(url);
if (!response.ok) throw new Error(`${what}: ${url} answered ${response.status}`);
return response.text();
}
/** The npm packument, reduced to what validation and the card need. */
export async function readNpm(name) {
const packument = await getJson(`https://registry.npmjs.org/${name.replace('/', '%2f')}`, `npm ${name}`);
@@ -76,6 +117,10 @@ export async function readNpm(name) {
devDependencies: version.devDependencies ?? {},
dependencies: version.dependencies ?? {},
peerDependencies: version.peerDependencies ?? {},
type: version.type,
main: version.main,
exports: version.exports,
readme: npmReadme(packument),
};
}
@@ -86,11 +131,15 @@ export async function readJsr(name) {
const info = await getJson(base, `jsr ${name}`);
const listing = await getJson(`${base}/versions`, `jsr ${name} versions`);
// `items`, not `latestVersion`. See newestVersion.
const versions = (listing.items ?? []).map((item) => item.version);
const versions = publishedVersions(listing.items ?? []);
const newest = newestVersion(versions);
const dependencies = newest ? await getJson(`${base}/versions/${newest}/dependencies`, `jsr ${name} deps`) : [];
const meta = newest ? await getJson(`${base}/versions/${newest}`, `jsr ${name} ${newest}`) : {};
const readme = meta.readmePath
? await getText(`https://jsr.io/${name}/${newest}${meta.readmePath}`, `jsr ${name} readme`)
: '';
return { versions, newest, runtimeCompat: info.runtimeCompat ?? {}, dependencies };
return { versions, newest, runtimeCompat: info.runtimeCompat ?? {}, dependencies, readme };
}
/**
@@ -109,7 +158,7 @@ export function declaredRuntimes({ engines, runtimeCompat }) {
}
/**
* Everything one card needs, live.
* Everything a card and a plugin page need, live.
*
* Under `CI` a registry that does not answer throws and fails the build, which is the rule that
* stops a stale or half-empty listing reaching production. Off CI it warns and returns `null`, and
@@ -118,18 +167,35 @@ export function declaredRuntimes({ engines, runtimeCompat }) {
export async function readEntry(entry) {
try {
const npm = entry.npm ? await readNpm(entry.npm) : undefined;
if (npm && !isEsmOnly(npm)) {
throw new Error(
`npm ${entry.npm}@${npm.newest} is not ESM only (type: ${npm.type ?? 'unset'}, main: ${npm.main ?? '-'}, exports: ${JSON.stringify(npm.exports ?? null)})`,
);
}
const jsr = entry.jsr ? await readJsr(entry.jsr) : undefined;
// JSR is the recommendation, so it is the source of the page whenever the entry declares it.
const from = jsr ? { registry: 'jsr', pkg: entry.jsr, info: jsr } : { registry: 'npm', pkg: entry.npm, info: npm };
const version = from.info.newest;
return {
version: (jsr ?? npm).newest,
registry: from.registry,
pkg: from.pkg,
version,
versions: byNewest(from.info.versions),
// npm's `engines` is the richer of the two — JSR's `runtimeCompat` is empty far more often,
// including on `@green-tea/core` itself — so it wins when both exist.
runtimes: declaredRuntimes({ engines: npm?.engines, runtimeCompat: jsr?.runtimeCompat }),
live: true,
readme: from.info.readme,
// Where the README's relative links point: the files of this exact published version.
readmeBase:
from.registry === 'jsr'
? `https://jsr.io/${from.pkg}/${version}/`
: `https://cdn.jsdelivr.net/npm/${from.pkg}@${version}/`,
};
} catch (error) {
if (STRICT) throw error;
console.warn(` left out, registry did not answer: ${entry.jsr ?? entry.npm} (${error.message})`);
console.warn(` left out: ${entry.jsr ?? entry.npm} (${error.message})`);
return null;
}
+99
View File
@@ -0,0 +1,99 @@
// Pure pieces of the registry reader. Network calls are not tested here; `CI=true npm run build`
// exercises them against the live registries.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { isEsmOnly, byNewest, npmReadme, publishedVersions } from './registry.mjs';
import { cleanReadme } from './readme.mjs';
test('isEsmOnly: type module with ESM exports passes', () => {
assert.equal(isEsmOnly({ type: 'module', exports: { '.': { import: './dist/index.js', types: './dist/index.d.ts' } } }), true);
});
test('isEsmOnly: no type module is CJS', () => {
assert.equal(isEsmOnly({ main: './index.js' }), false);
});
test('isEsmOnly: dual package is rejected', () => {
assert.equal(isEsmOnly({ type: 'module', exports: { '.': { import: './index.js', require: './index.cjs' } } }), false);
});
test('isEsmOnly: a .cjs anywhere in exports or main is rejected', () => {
assert.equal(isEsmOnly({ type: 'module', exports: { './legacy': './legacy.cjs' } }), false);
assert.equal(isEsmOnly({ type: 'module', main: './index.cjs' }), false);
});
test('byNewest: releases outrank their prereleases, betas order numerically', () => {
assert.deepEqual(byNewest(['26.9.0-beta.2', '26.9.0', '26.9.0-beta.10', '26.8.1']), [
'26.9.0',
'26.9.0-beta.10',
'26.9.0-beta.2',
'26.8.1',
]);
});
test('npmReadme: npm placeholder means no README', () => {
assert.equal(npmReadme({ readme: 'ERROR: No README data found!' }), '');
assert.equal(npmReadme({}), '');
assert.equal(npmReadme({ readme: '# hi' }), '# hi');
});
const BASE = 'https://jsr.io/@green-tea/jwt/26.9.0-beta.0/';
test('cleanReadme: strips scripts, handlers and javascript: links', () => {
const html = cleanReadme('<script>alert(1)</script><img src="x.png" onerror="x()"><a href="javascript:x()">a</a>', BASE);
assert.doesNotMatch(html, /script|onerror|javascript:/);
});
test('cleanReadme: keeps align and width (our READMEs center the logo)', () => {
const html = cleanReadme('<p align="center"><img src="https://x.io/l.png" width="96" alt="l"></p>', BASE);
assert.match(html, /<p align="center">/);
assert.match(html, /width="96"/);
});
test('cleanReadme: relative links and images point at the published version', () => {
const html = cleanReadme('<a href="./docs/a.md">a</a><img src="assets/l.png">', BASE);
assert.match(html, /href="https:\/\/jsr\.io\/@green-tea\/jwt\/26\.9\.0-beta\.0\/docs\/a\.md"/);
assert.match(html, /src="https:\/\/jsr\.io\/@green-tea\/jwt\/26\.9\.0-beta\.0\/assets\/l\.png"/);
const npm = cleanReadme('<img src="./l.png">', 'https://cdn.jsdelivr.net/npm/green-tea-foo@1.0.0/');
assert.match(npm, /src="https:\/\/cdn\.jsdelivr\.net\/npm\/green-tea-foo@1\.0\.0\/l\.png"/);
});
test('cleanReadme: leaves anchors alone', () => {
assert.match(cleanReadme('<a href="#install">i</a>', BASE), /href="#install"/);
});
test('cleanReadme: styles — shiki colours stay, layout tricks go', () => {
const html = cleanReadme(
'<pre class="astro-code" style="background-color:#24292e;overflow-x:auto"><span style="color:#F97583">x</span></pre><div style="position:fixed;inset:0">y</div>',
BASE,
);
assert.match(html, /color:#F97583/);
assert.match(html, /background-color:#24292e/);
assert.doesNotMatch(html, /position|inset/);
});
test('cleanReadme: an <a> without href does not become a link', () => {
const html = cleanReadme('<a name="x">t</a><img alt="n">', BASE);
assert.doesNotMatch(html, /href|src/);
});
test('cleanReadme: our own class names cannot be borrowed, shiki ones stay', () => {
const html = cleanReadme(
'<span class="card__link">x</span><span class="version">y</span><pre class="astro-code github-dark"><code class="language-ts"><span class="line">z</span></code></pre>',
BASE,
);
assert.doesNotMatch(html, /card__link|class="version"/);
assert.match(html, /class="astro-code github-dark"/);
assert.match(html, /class="line"/);
assert.match(html, /class="language-ts"/);
});
test('cleanReadme: <source srcset> points at the published version, descriptors kept', () => {
const html = cleanReadme('<picture><source media="(prefers-color-scheme: dark)" srcset="docs/dark.svg, docs/dark@2x.svg 2x"><img src="docs/l.svg"></picture>', BASE);
assert.match(html, /srcset="https:\/\/jsr\.io\/@green-tea\/jwt\/26\.9\.0-beta\.0\/docs\/dark\.svg, https:\/\/jsr\.io\/@green-tea\/jwt\/26\.9\.0-beta\.0\/docs\/dark@2x\.svg 2x"/);
});
test('publishedVersions: yanked JSR versions are not listed', () => {
assert.deepEqual(publishedVersions([{ version: '1.0.0', yanked: false }, { version: '1.0.1', yanked: true }]), ['1.0.0']);
});
+1 -1
View File
@@ -8,7 +8,7 @@ const linkColumns = [
{
heading: 'This listing',
links: [
{ label: 'Add your plugin', href: '#contribute', external: false },
{ label: 'Add your plugin', href: '/plugins/#contribute', external: false },
{
label: 'Source',
href: 'https://github.com/Expressive-Tea/green-tea-marketplace',
+1 -1
View File
@@ -6,7 +6,7 @@ import Icon from './Icon.astro';
// what this one is. The logo links out to green-tea rather than to `/`, because a reader who
// clicks a brand mark is asking for the project, and the project lives elsewhere.
const navLinks = [
{ label: 'Add your plugin', href: '#contribute', external: false },
{ label: 'Add your plugin', href: '/plugins/#contribute', external: false },
{ label: 'Docs', href: 'https://green-tea.expressive-tea.io/docs', external: true },
{ label: 'green-tea', href: 'https://green-tea.expressive-tea.io', external: true },
{
+5 -48
View File
@@ -1,13 +1,8 @@
---
import { RUNTIMES } from '../../scripts/registry.mjs';
// Brand marks from simple-icons (CC0), vendored rather than pulled at build time. `?raw` inlines
// them so each is one path in the HTML instead of four more requests.
import node from '../icons/nodedotjs.svg?raw';
import deno from '../icons/deno.svg?raw';
import bun from '../icons/bun.svg?raw';
import workerd from '../icons/cloudflareworkers.svg?raw';
import Runtimes from './Runtimes.astro';
interface Props {
slug: string;
name: string;
description: string;
repo: string;
@@ -18,52 +13,14 @@ interface Props {
internal: boolean;
}
const { name, description, repo, version, npm, jsr, runtimes, internal } = Astro.props;
const ICONS: Record<string, string> = { node, deno, bun, workerd };
const LABELS: Record<string, string> = {
node: 'Node.js',
deno: 'Deno',
bun: 'Bun',
workerd: 'workerd (Cloudflare Workers)',
};
// All four are always shown. Colour means the package declares it runs there; dim grey means it
// declared otherwise, or said nothing — the tooltip is what separates those two, because at a
// glance they are the same fact: you cannot use it there.
const runs = (runtime: string) => runtimes.includes(runtime);
const tooltip = (runtime: string) => {
if (runs(runtime)) return `Runs on ${LABELS[runtime]}`;
return internal
? `Does not run on ${LABELS[runtime]} — see the README for why`
: `${LABELS[runtime]} not declared by this package`;
};
const { slug, name, description, repo, version, npm, jsr, runtimes, internal } = Astro.props;
---
<article class="card">
<span class="version">{version}</span>
<h2>{name}</h2>
<h2><a class="card__link" href={`/plugins/${slug}/`}>{name}</a></h2>
<ul class="runtimes">
{
RUNTIMES.map((runtime) => (
// `data-tip` rather than `title`: the native tooltip waits about a second, cannot be
// styled, and — the reason it did not work at all here — loses to a `<title>` inside the
// SVG. The marks now carry no `<title>`, and the label lives on this element for both the
// tooltip and the screen reader. `tabindex` so it is reachable without a mouse.
<li
class={runs(runtime) ? 'yes' : 'no'}
data-tip={tooltip(runtime)}
role="img"
aria-label={tooltip(runtime)}
tabindex="0"
>
<Fragment set:html={ICONS[runtime]} />
</li>
))
}
</ul>
<Runtimes runtimes={runtimes} internal={internal} />
<p>{description}</p>
+56
View File
@@ -0,0 +1,56 @@
---
import { RUNTIMES } from '../../scripts/registry.mjs';
// Brand marks from simple-icons (CC0), vendored rather than pulled at build time. `?raw` inlines
// them so each is one path in the HTML instead of four more requests.
import node from '../icons/nodedotjs.svg?raw';
import deno from '../icons/deno.svg?raw';
import bun from '../icons/bun.svg?raw';
import workerd from '../icons/cloudflareworkers.svg?raw';
interface Props {
runtimes: string[];
internal: boolean;
}
const { runtimes, internal } = Astro.props;
const ICONS: Record<string, string> = { node, deno, bun, workerd };
const LABELS: Record<string, string> = {
node: 'Node.js',
deno: 'Deno',
bun: 'Bun',
workerd: 'workerd (Cloudflare Workers)',
};
// All four are always shown. Colour means the package declares it runs there; dim grey means it
// declared otherwise, or said nothing — the tooltip is what separates those two, because at a
// glance they are the same fact: you cannot use it there.
const runs = (runtime: string) => runtimes.includes(runtime);
const tooltip = (runtime: string) => {
if (runs(runtime)) return `Runs on ${LABELS[runtime]}`;
return internal
? `Does not run on ${LABELS[runtime]} — see the README for why`
: `${LABELS[runtime]} not declared by this package`;
};
---
<ul class="runtimes">
{
RUNTIMES.map((runtime) => (
// `data-tip` rather than `title`: the native tooltip waits about a second, cannot be
// styled, and — the reason it did not work at all here — loses to a `<title>` inside the
// SVG. The marks now carry no `<title>`, and the label lives on this element for both the
// tooltip and the screen reader. `tabindex` so it is reachable without a mouse.
<li
class={runs(runtime) ? 'yes' : 'no'}
data-tip={tooltip(runtime)}
role="img"
aria-label={tooltip(runtime)}
tabindex="0"
>
<Fragment set:html={ICONS[runtime]} />
</li>
))
}
</ul>
+47
View File
@@ -0,0 +1,47 @@
---
import { ADD_URL, CONTRIBUTING_URL } from '../../links';
---
<section class="section wrap">
<div class="front">
<h2>The listing is new. The first plugins get the front row.</h2>
<p>Every plugin here today is one of ours. The first community entries are the ones people will see first.</p>
<p class="front__actions">
<a class="button button--solid" href={ADD_URL}>Add your plugin</a>
<a class="button button--ghost" href={CONTRIBUTING_URL}>Read CONTRIBUTING.md</a>
</p>
</div>
</section>
<style>
.front {
text-align: center;
padding: clamp(2.5rem, 6vw, 4rem) clamp(1.5rem, 5vw, 3rem);
border: 1px solid var(--line);
border-radius: 16px;
background:
radial-gradient(ellipse at top, rgba(95, 184, 138, 0.14), transparent 60%),
radial-gradient(ellipse at bottom, rgba(124, 108, 240, 0.1), transparent 60%),
var(--panel);
}
.front h2 {
font-size: clamp(1.5rem, 4vw, 2.2rem);
margin: 0 auto 14px;
max-width: 24ch;
}
.front p {
color: var(--dim);
margin: 0 auto;
max-width: 56ch;
}
.front__actions {
display: flex;
gap: 0.75rem;
justify-content: center;
flex-wrap: wrap;
margin-top: 1.75rem !important;
}
</style>
+126
View File
@@ -0,0 +1,126 @@
---
import { Code } from 'astro:components';
import { ADD_URL } from '../../links';
// A whole plugin, written against the real `Plugin` type in core (src/plugin.ts). If that type
// changes, this has to change with it — it is the first thing a plugin author reads.
const SAMPLE = `import type { Plugin } from '@green-tea/core';
export function greeting(text = 'hello'): Plugin {
return {
name: 'greeting',
mount({ scope }) {
scope.add({
kind: 'provider',
name: 'greeting',
needs: [],
provides: ['greeting'],
run: () => ({ greeting: text }),
});
},
};
}`;
---
<section class="hero">
<div class="wrap hero__grid">
<div class="hero__content">
<p class="kicker">Green Tea. plugins</p>
<h1>Write it once. It mounts in any <span class="nowrap">green-tea</span> app.</h1>
<p class="hero__lead">
A plugin is a name and a mount function. It adds providers and steps to the graph, and
green-tea figures out where they run. Publish it to JSR or npm, list it here, and it gets a
page of its own.
</p>
<p class="hero__actions">
<a class="button button--solid" href={ADD_URL}>Add your plugin</a>
<a class="button button--ghost" href="#plugins">Browse plugins</a>
</p>
<p class="hero__micro">Needs <code>@green-tea/core@26.9.0-beta.2</code> or newer. Each card shows which runtimes that plugin supports.</p>
</div>
<figure class="hero__code" aria-label="A complete plugin">
<figcaption>greeting.ts</figcaption>
<Code code={SAMPLE} lang="ts" theme="github-dark" />
</figure>
</div>
</section>
<style>
.hero {
padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2rem, 5vw, 3.5rem);
}
.hero__grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
align-items: center;
gap: clamp(2rem, 5vw, 3.5rem);
}
.hero h1 {
font-size: clamp(2.2rem, 5.5vw, 3.3rem);
line-height: 1.15;
margin: 0 0 18px;
letter-spacing: -0.01em;
}
.hero__lead {
color: var(--dim);
max-width: 52ch;
margin: 0;
font-size: 1.08rem;
line-height: 1.7;
}
.hero__actions {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
margin: 1.75rem 0 1.25rem;
}
.hero__micro {
margin: 0;
color: var(--dim);
font-size: 0.85rem;
letter-spacing: 0.03em;
}
.hero__micro code {
font-family: var(--font-mono);
color: var(--ink);
}
.hero__code {
margin: 0;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
overflow: hidden;
box-shadow: 0 24px 60px -30px rgba(95, 184, 138, 0.35);
}
.hero__code figcaption {
padding: 10px 16px;
border-bottom: 1px solid var(--line);
color: var(--dim);
font-family: var(--font-mono);
font-size: 0.78rem;
}
.hero__code :global(pre) {
margin: 0;
padding: 16px 18px;
background: transparent !important;
font-size: 0.8rem;
line-height: 1.65;
overflow-x: auto;
}
@media (max-width: 900px) {
.hero__grid {
grid-template-columns: 1fr;
}
}
</style>
+89
View File
@@ -0,0 +1,89 @@
---
import { Code } from 'astro:components';
import { EXAMPLE_ENTRY } from '../../links';
// The editor gets the comment that explains npm; the card is too narrow for it.
const shown = EXAMPLE_ENTRY.replace(/[ \t]+#.*$/m, '').trim();
---
<section class="section wrap" id="contribute">
<p class="kicker">How it works</p>
<h2>Three steps</h2>
<ol class="steps">
<li class="step">
<h3>Publish</h3>
<p>Put it on JSR, or on npm as an ESM-only package.</p>
</li>
<li class="step step--wide">
<h3>Add one file</h3>
<p>Open a pull request that adds one yaml file.</p>
<Code code={shown} lang="yaml" theme="github-dark" />
</li>
<li class="step">
<h3>Go live</h3>
<p>Once it merges, it is out on the next Friday cut.</p>
</li>
</ol>
</section>
<style>
.steps {
list-style: none;
counter-reset: step;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: 1fr minmax(0, 2fr) 1fr;
gap: 20px;
}
.step {
counter-increment: step;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
padding: 22px 24px;
min-width: 0;
}
.step::before {
content: counter(step);
display: inline-grid;
place-items: center;
width: 30px;
height: 30px;
border-radius: 50%;
background: rgba(95, 184, 138, 0.12);
border: 1px solid rgba(95, 184, 138, 0.35);
color: var(--matcha);
font-family: var(--font-mono);
font-size: 0.85rem;
}
.step h3 {
margin: 12px 0 6px;
font-size: 1.1rem;
}
.step p {
margin: 0;
color: var(--dim);
}
.step :global(pre) {
margin: 14px 0 0;
padding: 12px 14px;
border-radius: 8px;
border: 1px solid var(--line);
font-size: 0.76rem;
line-height: 1.6;
overflow-x: auto;
}
@media (max-width: 900px) {
.steps {
grid-template-columns: 1fr;
}
}
</style>
@@ -0,0 +1,84 @@
---
// Every claim here is checked against core: the shape and the three-method API are
// `Plugin`/`PluginApi` in src/plugin.ts, and `mountPlugin` hands over nothing else.
//
// Make no isolation claims here at all. A plugin's step gets the live request context and can
// overwrite keys in it (see mountPlugin's comment), and a plugin node can replace an app step: a
// plugin node that
// provides a token an app step already provides wins in `topoSort`/`subgraphFor` (src/graph.ts,
// `producedBy.set`, last one in), and the app's step drops out of the graph with no error.
// Verified 2026-09-24. Only duplicate node *names* are a boot error.
//
// The claim is execution order derived from needs/provides, and nothing more. Registration order
// is NOT irrelevant: with two producers of one token, the one registered last wins, so never
// write "no need to register X first".
const points = [
{
title: 'One object',
body: '<code>{ name, mount }</code>. No base class to extend and no lifecycle to learn. <code>mount</code> gets <code>bus.on</code>, <code>scope.add</code> and <code>onShutdown</code>, and that is the whole API.',
},
{
title: 'Core as types only',
body: 'Plugins import <code>@green-tea/core</code> with <code>import type</code> and keep it out of <code>dependencies</code>, and review checks for it. So installing one does not pull in a second copy of core.',
},
{
title: 'The graph picks the order',
body: 'Say what your plugin needs and what it provides, and green-tea works out where it runs.',
},
];
---
<section class="section wrap">
<p class="kicker">The idea</p>
<h2>What's a plugin, and why write one?</h2>
<div class="points">
{
points.map((point, i) => (
<article class="point">
<span class="point__n" aria-hidden="true">{String(i + 1).padStart(2, '0')}</span>
<h3>{point.title}</h3>
<p set:html={point.body} />
</article>
))
}
</div>
</section>
<style>
.points {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 20px;
}
.point {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
padding: 22px 24px;
}
.point__n {
font-family: var(--font-mono);
font-size: 0.78rem;
color: var(--violet);
}
.point h3 {
margin: 6px 0 10px;
font-size: 1.15rem;
}
.point p {
margin: 0;
color: var(--dim);
line-height: 1.65;
}
.point :global(code) {
font-family: var(--font-mono);
font-size: 0.88em;
color: var(--matcha);
}
</style>
+55
View File
@@ -0,0 +1,55 @@
---
// Nothing here promises traffic or reach. Each line is something the listing already does.
const reasons = [
{ title: 'A page of its own', body: 'Your README, every published version and an install command people can copy.' },
{ title: 'Runtimes read, not typed', body: 'Each card shows where your plugin runs, taken from what the package declares.' },
{
title: "It doesn't go stale",
body: 'Your entry has no version in it. Each rebuild of the listing asks the registry again, so your card picks up a new release without you touching the entry.',
},
{ title: 'Read by a person', body: 'Someone who works on green-tea reads each entry before it is listed.' },
];
---
<section class="section wrap">
<p class="kicker">Why here</p>
<h2>Why list it here</h2>
<dl class="reasons">
{
reasons.map((reason) => (
<div class="reason">
<dt>{reason.title}</dt>
<dd>{reason.body}</dd>
</div>
))
}
</dl>
</section>
<style>
.reasons {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 28px 36px;
margin: 0;
}
.reason {
border-left: 2px solid var(--matcha);
padding-left: 16px;
}
.reason dt {
font-family: var(--font-heading);
font-weight: 700;
font-size: 1.05rem;
margin-bottom: 6px;
}
.reason dd {
margin: 0;
color: var(--dim);
line-height: 1.65;
}
</style>
+25 -15
View File
@@ -1,5 +1,6 @@
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
import { pluginsLoader } from '../scripts/loader.mjs';
// Naming, from spec 5.2. Enforced here so a wrongly-named submission is rejected by the build
// rather than by a reviewer's memory.
@@ -8,21 +9,30 @@ import { glob } from 'astro/loaders';
const NPM_NAME = /^(@green-tea\/[a-z0-9-]+|green-tea-[a-z0-9-]+|@[a-z0-9-]+\/green-tea-[a-z0-9-]+)$/;
const JSR_NAME = /^@[a-z0-9-]+\/(green-tea-)?[a-z0-9-]+$/;
// `npm` and `jsr` rather than one `name`: a third party's package has a different name on each
// registry. No `version` and no `runtimes` — both come from the registry, so an entry cannot go
// stale or claim a runtime the package never declared.
const FIELDS = z.object({
npm: z.string().regex(NPM_NAME, 'npm name must be @green-tea/<x>, green-tea-<x> or @scope/green-tea-<x>').optional(),
jsr: z.string().regex(JSR_NAME, 'JSR name must be @scope/<x>').optional(),
repo: z.string().url(),
description: z.string().min(20).max(200),
});
const ENTRY = FIELDS.refine((entry) => entry.npm ?? entry.jsr, {
message: 'an entry needs at least one of npm / jsr — otherwise there is nothing to install',
});
const plugins = defineCollection({
loader: glob({ pattern: '**/[^_]*.yaml', base: './src/content/plugins' }),
schema: z
.object({
// `npm` and `jsr` rather than one `name`: a third party's package has a different name on
// each registry. No `version` and no `runtimes` — both come from the registry, so an entry
// cannot go stale or claim a runtime the package never declared.
npm: z.string().regex(NPM_NAME, 'npm name must be @green-tea/<x>, green-tea-<x> or @scope/green-tea-<x>').optional(),
jsr: z.string().regex(JSR_NAME, 'JSR name must be @scope/<x>').optional(),
repo: z.string().url(),
description: z.string().min(20).max(200),
})
.refine((entry) => entry.npm ?? entry.jsr, {
message: 'an entry needs at least one of npm / jsr — otherwise there is nothing to install',
}),
loader: pluginsLoader(ENTRY),
// What the loader stores: the entry plus what the registry said.
schema: FIELDS.extend({
pkg: z.string(),
registry: z.enum(['jsr', 'npm']),
version: z.string(),
versions: z.array(z.string()),
runtimes: z.array(z.string()),
}),
});
export const collections = { plugins };
+13
View File
@@ -0,0 +1,13 @@
// Links more than one section needs. The GitHub repo does not exist yet, so these 404 until it does.
/** What "Add your plugin" pre-fills in GitHub's new-file editor. */
export const EXAMPLE_ENTRY = `jsr: "@your-scope/green-tea-your-plugin" # recommended. Or npm: green-tea-your-plugin (ESM only)
repo: https://github.com/you/green-tea-your-plugin
description: "One sentence, 20 to 200 characters."
`;
// GitHub's new-file editor, inside this repo, with the example already filled in: a contributor
// edits a few lines and opens the pull request from there.
export const ADD_URL = `https://github.com/Expressive-Tea/green-tea-marketplace/new/main/src/content/plugins?filename=green-tea-your-plugin.yaml&value=${encodeURIComponent(EXAMPLE_ENTRY)}`;
export const CONTRIBUTING_URL = 'https://github.com/Expressive-Tea/green-tea-marketplace/blob/main/CONTRIBUTING.md';
+94
View File
@@ -0,0 +1,94 @@
---
import { getCollection, render } from 'astro:content';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import Runtimes from '../components/Runtimes.astro';
import '../styles/global.css';
export async function getStaticPaths() {
return (await getCollection('plugins')).map((entry) => ({ params: { slug: entry.id }, props: { entry } }));
}
const { entry } = Astro.props;
const { data } = entry;
const { Content } = await render(entry);
const hasReadme = Boolean(entry.rendered?.html);
const internal = data.pkg.startsWith('@green-tea/');
const install = data.registry === 'jsr' ? `npx jsr add ${data.pkg}` : `npm i ${data.pkg}`;
const versionUrl = (v: string) =>
data.registry === 'jsr' ? `https://jsr.io/${data.pkg}@${v}` : `https://www.npmjs.com/package/${data.pkg}/v/${v}`;
const registryUrl = data.registry === 'jsr' ? `https://jsr.io/${data.pkg}` : `https://www.npmjs.com/package/${data.pkg}`;
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" href="/plugins/favicon.svg" type="image/svg+xml" />
<title>{data.pkg} · Green Tea. plugins</title>
<meta name="description" content={data.description} />
<link rel="canonical" href={`https://green-tea.expressive-tea.io/plugins/${entry.id}/`} />
</head>
<body>
<Header />
<main class="wrap plugin">
<header class="plugin__head">
<p class="plugin__back"><a href="/plugins/">&larr; All plugins</a></p>
<h1>{data.pkg} <span class="version">{data.version}</span></h1>
<p>{data.description}</p>
<Runtimes runtimes={data.runtimes} internal={internal} />
<div class="install">
<code>{install}</code>
<button type="button" class="button" data-copy={install} aria-live="polite">Copy</button>
</div>
<p class="requires">Needs <code>@green-tea/core@26.9.0-beta.2</code> or newer.</p>
<p class="links">
<a href={registryUrl}>{data.registry === 'jsr' ? 'JSR' : 'npm'}</a>
<a href={data.repo}>source</a>
</p>
</header>
<div class="plugin__body">
<article class="readme">
{
hasReadme ? (
<Content />
) : (
<p>
This package publishes no README. <a href={registryUrl}>See it on the registry.</a>
</p>
)
}
</article>
<aside class="versions" aria-label="Versions">
<h2>Versions</h2>
<ol>
{
data.versions.map((v) => (
<li>
<a href={versionUrl(v)}>{v}</a>
</li>
))
}
</ol>
</aside>
</div>
</main>
<Footer />
<script>
for (const button of document.querySelectorAll<HTMLButtonElement>('[data-copy]')) {
button.addEventListener('click', async () => {
await navigator.clipboard.writeText(button.dataset.copy ?? '');
button.textContent = 'Copied';
setTimeout(() => (button.textContent = 'Copy'), 1500);
});
}
</script>
</body>
</html>
+31 -69
View File
@@ -1,37 +1,31 @@
---
import { getCollection } from 'astro:content';
import { readEntry } from '../../scripts/registry.mjs';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import PluginCard from '../components/PluginCard.astro';
import Hero from '../components/sections/Hero.astro';
import WhatIsAPlugin from '../components/sections/WhatIsAPlugin.astro';
import WhyHere from '../components/sections/WhyHere.astro';
import HowItWorks from '../components/sections/HowItWorks.astro';
import FrontRow from '../components/sections/FrontRow.astro';
import '../styles/global.css';
// Read at build time, never at request time — this site is static files on cPanel. Under CI a
// registry that does not answer fails the build; off CI that entry is left out. See
// scripts/registry.mjs.
const entries = await getCollection('plugins');
const plugins = (
await Promise.all(
entries.map(async (entry) => {
const live = await readEntry(entry.data);
if (!live) return null;
return {
name: entry.data.jsr ?? entry.data.npm,
description: entry.data.description,
repo: entry.data.repo,
npm: entry.data.npm,
jsr: entry.data.jsr,
version: live.version,
runtimes: live.runtimes,
// An internal plugin could be listed on npm alone and still be ours, so check both fields.
internal: (entry.data.jsr ?? entry.data.npm ?? '').startsWith('@green-tea/'),
};
}),
)
).filter((plugin) => plugin !== null);
plugins.sort((a, b) => a.name.localeCompare(b.name));
// Read at build time by the collection's loader (scripts/loader.mjs) — this site is static files
// on cPanel. Under CI a registry that does not answer fails the build; off CI that entry is left out.
const plugins = (await getCollection('plugins'))
.map(({ id, data }) => ({
slug: id,
name: data.pkg,
description: data.description,
repo: data.repo,
npm: data.npm,
jsr: data.jsr,
version: data.version,
runtimes: data.runtimes,
// An internal plugin could be listed on npm alone and still be ours, so check both fields.
internal: (data.jsr ?? data.npm ?? '').startsWith('@green-tea/'),
}))
.sort((a, b) => a.name.localeCompare(b.name));
---
<html lang="en">
@@ -40,60 +34,28 @@ plugins.sort((a, b) => a.name.localeCompare(b.name));
<meta name="viewport" content="width=device-width" />
<link rel="icon" href="/plugins/favicon.svg" type="image/svg+xml" />
<title>Green Tea. plugins</title>
<meta name="description" content="Plugins for green-tea, with the runtimes each one declares." />
<meta name="description" content="List your green-tea plugin. JSR recommended; npm works too, as long as it is ESM only." />
<link rel="canonical" href="https://green-tea.expressive-tea.io/plugins" />
</head>
<body>
<Header />
<main>
<section class="hero wrap">
<h1>Plugins</h1>
<p class="hero__lead">
A plugin is a named object that adds steps and providers to your graph. It imports
green-tea as types only, so installing one never pulls a second copy of core.
</p>
<p class="requires">
Everything here needs <code>@green-tea/core@26.9.0-beta.2</code> or newer. That is the
release where a plugin became <code>&#123; name, mount &#125;</code> and
<code>app.boot()</code> went public; on anything older these will not mount.
</p>
</section>
<Hero />
<WhatIsAPlugin />
<section class="wrap">
<section class="section wrap" id="plugins">
<p class="kicker">The listing</p>
<h2>Official plugins, and room for yours</h2>
<p class="section__lead">Three to start. The version and runtimes on each card come straight from the registry.</p>
<div class="grid">
{plugins.map((plugin) => <PluginCard {...plugin} />)}
</div>
</section>
<section class="contribute wrap" id="contribute">
<h2>Add your plugin</h2>
<p>
Fork the listing, add one file under <code>src/content/plugins/</code>, open a pull
request. There is no version and no runtimes field — both are read from the registry, so
your entry cannot go stale.
</p>
<pre><code>npm: green-tea-foo # at least one of npm / jsr
jsr: "@acme/green-tea-foo"
repo: https://github.com/acme/green-tea-foo
description: "One sentence, 20–200 characters."</code></pre>
<p>
A check runs against npm and JSR: the package has to exist, depend on
<code>@green-tea/core</code>, and declare at least one runtime. Then a person reads it —
that it really is a factory returning <code>&#123; name, mount &#125;</code>, and that its
README lists all four runtimes with a reason beside each one it does not support.
</p>
<p class="contribute__cadence">
Merged entries go live on the next <strong>Friday</strong> cut.
</p>
<p>
<a class="button" href="https://github.com/Expressive-Tea/green-tea-marketplace">
Open the listing on GitHub &rarr;
</a>
</p>
</section>
<WhyHere />
<HowItWorks />
<FrontRow />
</main>
<Footer />
+65 -58
View File
@@ -72,75 +72,34 @@ main {
display: block;
}
.hero {
padding-top: clamp(3rem, 7vw, 5rem);
/* Each home section brings its own layout; this is the rhythm they share. */
.section {
padding-top: clamp(3.5rem, 8vw, 5.5rem);
}
.hero h1 {
font-size: clamp(2.2rem, 6vw, 3.4rem);
margin: 0 0 16px;
letter-spacing: -0.01em;
.section h2 {
font-size: clamp(1.6rem, 4vw, 2.2rem);
margin: 0 0 24px;
}
.hero__lead {
.section__lead {
color: var(--dim);
margin: -12px 0 24px;
max-width: 62ch;
margin: 0;
font-size: 1.05rem;
}
/* Full container width, like every other section, so its left edge lines up with the cards above.
The reading measure is capped on the prose instead — the same split the hero already uses,
where `.hero__lead` is narrow inside a full-width `.hero`. Capping the section itself centred it
at a narrower width and knocked the whole block out of alignment. */
.contribute {
padding-top: clamp(3rem, 7vw, 4.5rem);
/* Keeps a hyphenated name like green-tea on one line in a large heading. */
.nowrap {
white-space: nowrap;
}
.contribute h2 {
font-size: clamp(1.5rem, 4vw, 2rem);
margin: 0 0 16px;
}
.contribute p {
color: var(--dim);
margin: 0 0 16px;
max-width: 68ch;
}
/* The snippet is short and fixed, so it sizes to the prose rather than stretching to the grid. */
.contribute pre {
max-width: 68ch;
}
.contribute code {
font-family: var(--font-mono);
font-size: 0.9em;
color: var(--ink);
}
.contribute pre {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 10px;
padding: 16px 18px;
overflow-x: auto;
margin: 0 0 20px;
}
.contribute pre code {
font-size: 0.82rem;
line-height: 1.7;
color: var(--ink);
}
.contribute__cadence {
border-left: 3px solid var(--matcha);
padding-left: 14px;
}
.contribute__cadence strong {
.kicker {
margin: 0 0 8px;
color: var(--matcha);
font-family: var(--font-mono);
font-size: 0.78rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.button {
@@ -159,6 +118,18 @@ main {
border-color: var(--matcha);
}
/* The one action the page is for. */
.button--solid {
background: var(--matcha);
border-color: var(--matcha);
color: var(--base);
}
.button--solid:hover {
background: var(--matcha-deep);
border-color: var(--matcha-deep);
}
/* The one thing a reader has to know before installing anything here. */
.requires {
margin: 24px 0 0;
@@ -386,3 +357,39 @@ main {
color: var(--matcha);
}
/* The whole card opens the plugin's page; the registry links and runtime marks stay clickable on
top of it. A stretched link rather than a wrapping <a>, because links cannot nest. */
.card__link { color: inherit; text-decoration: none; }
.card__link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.card .links, .card .why, .card .runtimes { position: relative; z-index: 1; }
.card:has(.card__link:focus-visible) { outline: 2px solid var(--matcha); outline-offset: 2px; }
.card:has(.card__link:hover) { border-color: var(--matcha-deep); }
/* Plugin page. */
.plugin__head { padding-block: 2rem 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.plugin__back a { color: var(--dim); text-decoration: none; }
.plugin__back a:hover { color: var(--matcha); }
.plugin__head h1 { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; font-family: var(--font-mono); word-break: break-word; }
.plugin__head .version { position: static; }
.install { display: flex; gap: 0.5rem; align-items: center; margin-block: 1rem 0.25rem; flex-wrap: wrap; }
.install code { padding: 0.5rem 0.75rem; border-radius: 6px; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); font-family: var(--font-mono); }
.plugin__body { display: grid; grid-template-columns: minmax(0, 1fr) 12rem; gap: 2rem; padding-bottom: 3rem; }
.readme { min-width: 0; line-height: 1.6; }
.readme img { max-width: 100%; height: auto; }
.readme pre { overflow-x: auto; padding: 1rem; border-radius: 6px; border: 1px solid var(--line); }
.readme a { color: var(--matcha); }
.readme table { border-collapse: collapse; display: block; overflow-x: auto; }
.readme th, .readme td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; }
.versions h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.versions ol { list-style: none; padding: 0; margin: 0; font-family: var(--font-mono); font-size: 0.9rem; }
.versions li { padding-block: 0.2rem; }
.versions a { color: var(--ink); }
.versions a:hover { color: var(--matcha); }
@media (max-width: 48rem) {
.plugin__body { grid-template-columns: 1fr; }
.versions { order: -1; }
}
.button--ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.button--ghost:hover { border-color: var(--matcha); }