Skip to content

Commit db2766d

Browse files
committed
Merge branch 'docs/refs'
2 parents c094e49 + 9ec4aef commit db2766d

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ When adding a new package to the monorepo, the following files must be updated:
197197
*docs/manual/integration.md*.
198198
- If the package implements `KvStore`: Update *docs/manual/kv.md*.
199199
- If the package implements `MessageQueue`: Update *docs/manual/mq.md*.
200-
- If the package is published to JSR: Add JSR link to the `REFERENCES` data
201-
in *docs/.vitepress/config.mts* (note: only JSR links are added here,
202-
not npm links; *@fedify/cli* and *@fedify/lint* are excluded from
203-
REFERENCES).
200+
- If the package is published to JSR: Ensure the package's *deno.json*
201+
contains the correct `name` and `publish` metadata. The docs “References”
202+
section is generated automatically from publishable workspace packages, so
203+
no manual change to *docs/.vitepress/config.mts* is needed.
204204

205205
**Optional updates:**
206206

docs/.vitepress/config.mts

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import abbr from "markdown-it-abbr";
33
import deflist from "markdown-it-deflist";
44
import footnote from "markdown-it-footnote";
55
import { jsrRef } from "markdown-it-jsr-ref";
6+
import { readFileSync } from "node:fs";
67
import process from "node:process";
78
import { ModuleKind, ModuleResolutionKind, ScriptTarget } from "typescript";
89
import { defineConfig } from "vitepress";
@@ -43,6 +44,48 @@ if (process.env.PLAUSIBLE_DOMAIN) {
4344
];
4445
}
4546

47+
interface RootDenoConfig {
48+
workspace?: string[];
49+
}
50+
51+
interface PackageDenoConfig {
52+
name?: string;
53+
publish?: boolean | { exclude?: string[] };
54+
}
55+
56+
function getReferenceItems(): { text: string; link: string }[] {
57+
const repoRootUrl = new URL("../../", import.meta.url);
58+
const rootDenoConfig = JSON.parse(
59+
readFileSync(new URL("deno.json", repoRootUrl), "utf-8"),
60+
) as RootDenoConfig;
61+
62+
const names = new Set<string>();
63+
for (const workspaceEntry of rootDenoConfig.workspace ?? []) {
64+
if (!workspaceEntry.startsWith("./packages/")) continue;
65+
const packageDenoJsonUrl = new URL(`${workspaceEntry}/deno.json`, repoRootUrl);
66+
const packageDenoConfig = JSON.parse(
67+
readFileSync(packageDenoJsonUrl, "utf-8"),
68+
) as PackageDenoConfig;
69+
if (packageDenoConfig.publish === false || packageDenoConfig.name == null) {
70+
continue;
71+
}
72+
names.add(packageDenoConfig.name);
73+
}
74+
75+
return Array.from(names)
76+
.sort((a, b) =>
77+
a === "@fedify/fedify"
78+
? -1
79+
: b === "@fedify/fedify"
80+
? 1
81+
: a.localeCompare(b)
82+
)
83+
.map((name) => ({
84+
text: name,
85+
link: `https://jsr.io/${name}/doc`,
86+
}));
87+
}
88+
4689
const TUTORIAL = {
4790
text: "Tutorials",
4891
items: [
@@ -88,30 +131,7 @@ const MANUAL = {
88131

89132
const REFERENCES = {
90133
text: "References",
91-
items: [
92-
// Don't include @fedify/cli and @fedify/lint here
93-
{ text: "@fedify/fedify", link: "https://jsr.io/@fedify/fedify/doc" },
94-
{ text: "@fedify/amqp", link: "https://jsr.io/@fedify/amqp/doc" },
95-
{ text: "@fedify/astro", link: "https://jsr.io/@fedify/astro/doc" },
96-
{ text: "@fedify/cfworkers", link: "https://jsr.io/@fedify/cfworkers/doc" },
97-
{ text: "@fedify/debugger", link: "https://jsr.io/@fedify/debugger/doc" },
98-
{ text: "@fedify/denokv", link: "https://jsr.io/@fedify/denokv/doc" },
99-
{ text: "@fedify/express", link: "https://jsr.io/@fedify/express/doc" },
100-
{ text: "@fedify/fastify", link: "https://jsr.io/@fedify/fastify/doc" },
101-
{ text: "@fedify/fresh", link: "https://jsr.io/@fedify/fresh/doc" },
102-
{ text: "@fedify/h3", link: "https://jsr.io/@fedify/h3/doc" },
103-
{ text: "@fedify/hono", link: "https://jsr.io/@fedify/hono/doc" },
104-
{ text: "@fedify/koa", link: "https://jsr.io/@fedify/koa/doc" },
105-
{ text: "@fedify/mysql", link: "https://jsr.io/@fedify/mysql/doc" },
106-
{ text: "@fedify/postgres", link: "https://jsr.io/@fedify/postgres/doc" },
107-
{ text: "@fedify/redis", link: "https://jsr.io/@fedify/redis/doc" },
108-
{ text: "@fedify/relay", link: "https://jsr.io/@fedify/relay/doc" },
109-
{ text: "@fedify/sqlite", link: "https://jsr.io/@fedify/sqlite/doc" },
110-
{ text: "@fedify/sveltekit", link: "https://jsr.io/@fedify/sveltekit/doc" },
111-
{ text: "@fedify/testing", link: "https://jsr.io/@fedify/testing/doc" },
112-
{ text: "@fedify/vocab-runtime", link: "https://jsr.io/@fedify/vocab-runtime/doc" },
113-
{ text: "@fedify/vocab-tools", link: "https://jsr.io/@fedify/vocab-tools/doc" },
114-
],
134+
items: getReferenceItems(),
115135
};
116136

117137
export default withMermaid(defineConfig({

0 commit comments

Comments
 (0)