doccupine 0.0.135 → 0.0.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,6 +89,7 @@ updated: "2025-02-01" # Last-modified date (JSON-LD dateModified)
89
89
  section: "API Reference" # Section this page belongs to
90
90
  sectionOrder: 1 # Sort order for the section in the tab bar
91
91
  openapi: "GET /users/{id}" # Embed an API playground for this endpoint (see API Reference)
92
+ rss: true # Show an RSS button linking to the page's feed (pages with Update components)
92
93
  ---
93
94
  ```
94
95
 
package/dist/index.js CHANGED
@@ -1321,10 +1321,17 @@ export default function Page() {
1321
1321
  openapi: typeof frontmatter.openapi === "string"
1322
1322
  ? frontmatter.openapi
1323
1323
  : undefined,
1324
+ rss: frontmatter.rss === true,
1324
1325
  };
1325
1326
  break;
1326
1327
  }
1327
1328
  }
1329
+ // The homepage publishes the same subscribable changelog as any other
1330
+ // page (see generatePageFromMDX): <Update> blocks feed the site-root
1331
+ // /rss.xml, and `rss: true` frontmatter opts into the RSS button.
1332
+ const updates = indexMDX ? parseUpdateBlocks(indexMDX.content) : [];
1333
+ const hasFeed = updates.length > 0;
1334
+ const feedPath = "/rss.xml";
1328
1335
  const metadataBlock = indexMDX
1329
1336
  ? generateMetadataBlock({
1330
1337
  title: indexMDX.title,
@@ -1335,6 +1342,7 @@ export default function Page() {
1335
1342
  icon: indexMDX.icon,
1336
1343
  image: indexMDX.image,
1337
1344
  canonicalPath: "",
1345
+ rssPath: hasFeed ? feedPath : undefined,
1338
1346
  })
1339
1347
  : generateRuntimeOnlyMetadataBlock();
1340
1348
  const homeJsonLd = generateJsonLdScript({
@@ -1361,11 +1369,18 @@ export default function Page() {
1361
1369
  const apiConst = apiOperation
1362
1370
  ? `\nconst operation = JSON.parse(${JSON.stringify(JSON.stringify(apiOperation))});\n`
1363
1371
  : "";
1372
+ // Same gating as generatePageFromMDX: the playground branch keeps its
1373
+ // fixed JSX shape, so a feed on a playground homepage stays reachable via
1374
+ // autodiscovery. The buttoned inline form stays within the 80-col print
1375
+ // width at its 6-space insertion indent, so it is Prettier-stable as is.
1376
+ const showRssButton = hasFeed && indexMDX?.rss === true && !apiOperation;
1364
1377
  const docsElement = apiOperation
1365
1378
  ? `<Docs content={content} sourcePath="index.mdx">
1366
1379
  <ApiPlayground operation={operation} />
1367
1380
  </Docs>`
1368
- : `<Docs content={content} sourcePath="index.mdx" />`;
1381
+ : showRssButton
1382
+ ? `<Docs content={content} sourcePath="index.mdx" rssHref={"/rss.xml"} />`
1383
+ : `<Docs content={content} sourcePath="index.mdx" />`;
1369
1384
  const indexContent = `import { Metadata } from "next";
1370
1385
  import { Docs } from "@/components/Docs";
1371
1386
  import { config } from "@/utils/config";${apiImport}
@@ -1391,8 +1406,38 @@ export default function Home() {
1391
1406
  const homePath = path.join(this.outputDir, "app", "(site)", "page.tsx");
1392
1407
  await fs.ensureDir(path.dirname(homePath));
1393
1408
  await fs.writeFile(homePath, indexContent, "utf8");
1409
+ // Same lifecycle as the per-page feeds in generatePageFromMDX: write the
1410
+ // root feed route while the homepage has Update blocks, prune it when
1411
+ // they go away or index.mdx is deleted (this runs on every aggregate
1412
+ // refresh, including the delete path).
1413
+ const rssDir = path.join(this.outputDir, "app", "(site)", "rss.xml");
1414
+ if (hasFeed && indexMDX) {
1415
+ await fs.ensureDir(rssDir);
1416
+ await fs.writeFile(path.join(rssDir, "route.ts"), rssRouteTemplate({
1417
+ pagePath: "",
1418
+ title: indexMDX.title,
1419
+ description: indexMDX.description || null,
1420
+ items: updates.map((update) => ({
1421
+ title: update.label,
1422
+ anchor: update.anchor,
1423
+ description: update.description,
1424
+ })),
1425
+ }), "utf8");
1426
+ }
1427
+ else {
1428
+ await fs.remove(rssDir);
1429
+ }
1394
1430
  }
1395
1431
  async updateSectionIndex(sectionSlug, frontmatter, mdxContent, sourcePath) {
1432
+ // This overwrites the page generatePageFromMDX just wrote for the same
1433
+ // slug (section landings compose their metadata name-first), so the RSS
1434
+ // state must be re-derived here or the overwrite silently drops the
1435
+ // button and autodiscovery - the feed route survives either way since it
1436
+ // lives in a sibling rss.xml/ dir.
1437
+ const updates = parseUpdateBlocks(mdxContent);
1438
+ const hasFeed = updates.length > 0;
1439
+ const feedPath = `/${sectionSlug}/rss.xml`;
1440
+ const showRssButton = hasFeed && frontmatter.rss === true;
1396
1441
  const metadataBlock = generateMetadataBlock({
1397
1442
  title: frontmatter.title,
1398
1443
  titleFallback: "Section",
@@ -1402,6 +1447,7 @@ export default function Home() {
1402
1447
  icon: frontmatter.icon,
1403
1448
  image: frontmatter.image,
1404
1449
  canonicalPath: sectionSlug,
1450
+ rssPath: hasFeed ? feedPath : undefined,
1405
1451
  });
1406
1452
  const sectionJsonLd = generateJsonLdScript({
1407
1453
  kind: "article",
@@ -1416,6 +1462,18 @@ export default function Home() {
1416
1462
  : undefined,
1417
1463
  image: frontmatter.image,
1418
1464
  });
1465
+ // Same Prettier pre-wrap contract as generatePageFromMDX: the buttoned
1466
+ // form usually pushes the line past the 80-col print width, so emit it
1467
+ // with attributes on their own lines relative to the 6-space indent.
1468
+ const docsAttrs = [
1469
+ `content={content}`,
1470
+ `sourcePath={${JSON.stringify(sourcePath ?? `${sectionSlug}/index.mdx`)}}`,
1471
+ ...(showRssButton ? [`rssHref={${JSON.stringify(feedPath)}}`] : []),
1472
+ ];
1473
+ const inlineDocs = `<Docs ${docsAttrs.join(" ")} />`;
1474
+ const docsElement = inlineDocs.length + 6 <= 80
1475
+ ? inlineDocs
1476
+ : `<Docs\n${docsAttrs.map((attr) => ` ${attr}`).join("\n")}\n />`;
1419
1477
  const indexContent = `import { Metadata } from "next";
1420
1478
  import { Docs } from "@/components/Docs";
1421
1479
  import { config } from "@/utils/config";
@@ -1433,7 +1491,7 @@ export default function Page() {
1433
1491
  return (
1434
1492
  <>
1435
1493
  ${sectionJsonLd.element}
1436
- <Docs content={content} sourcePath={${JSON.stringify(sourcePath ?? `${sectionSlug}/index.mdx`)}} />
1494
+ ${docsElement}
1437
1495
  </>
1438
1496
  );
1439
1497
  }
@@ -1 +1 @@
1
- export declare const rssLibTemplate = "import { config } from \"@/utils/config\";\n\nexport interface RssItem {\n title: string;\n anchor: string;\n description: string;\n}\n\nexport interface RssFeedData {\n // Page path relative to the site root, e.g. \"update\" or \"guides/setup\".\n pagePath: string;\n // Channel title; null falls back to the site name from config.json.\n title: string | null;\n // Channel description; null falls back to the config.json description.\n description: string | null;\n items: RssItem[];\n}\n\n// Same base-URL resolution as sitemap.ts/robots.ts: env override first, then\n// config.json. Without either, feed links degrade to root-relative paths.\nfunction resolveBaseUrl(): string | null {\n const raw = process.env.NEXT_PUBLIC_SITE_URL ?? config.url;\n if (!raw) return null;\n return raw.replace(/\\/$/, \"\");\n}\n\n// Ampersand first, or it would re-escape the other entities.\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\");\n}\n\n// Builds the RSS 2.0 document for a page's subscribable changelog. Entry\n// descriptions arrive as pure Markdown (components, code, and HTML were\n// removed at generation time) and are entity-escaped here, so no CDATA\n// sections are needed. Entries carry no pubDate: the guid is the entry's\n// permalink, so feed readers surface new entries when new guids appear.\nexport function buildRssFeed(feed: RssFeedData): string {\n const base = resolveBaseUrl();\n const pageUrl = base ? `${base}/${feed.pagePath}` : `/${feed.pagePath}`;\n const feedUrl = `${pageUrl}/rss.xml`;\n const siteName = config.name || \"Documentation\";\n const title = feed.title ?? siteName;\n const description = feed.description ?? config.description ?? title;\n\n const items = feed.items.map((item) => {\n const link = `${pageUrl}#${item.anchor}`;\n return [\n \" <item>\",\n ` <title>${escapeXml(item.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(item.description)}</description>`,\n \" </item>\",\n ].join(\"\\n\");\n });\n\n return [\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>`,\n `<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">`,\n \" <channel>\",\n ` <title>${escapeXml(title)}</title>`,\n ` <link>${escapeXml(pageUrl)}</link>`,\n ` <description>${escapeXml(description)}</description>`,\n ` <atom:link href=\"${escapeXml(feedUrl)}\" rel=\"self\" type=\"application/rss+xml\" />`,\n ` <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>`,\n ` <copyright>${escapeXml(siteName)}</copyright>`,\n ...items,\n \" </channel>\",\n \"</rss>\",\n \"\",\n ].join(\"\\n\");\n}\n";
1
+ export declare const rssLibTemplate = "import { config } from \"@/utils/config\";\n\nexport interface RssItem {\n title: string;\n anchor: string;\n description: string;\n}\n\nexport interface RssFeedData {\n // Page path relative to the site root, e.g. \"update\" or \"guides/setup\".\n // Empty string means the homepage feed (served from /rss.xml).\n pagePath: string;\n // Channel title; null falls back to the site name from config.json.\n title: string | null;\n // Channel description; null falls back to the config.json description.\n description: string | null;\n items: RssItem[];\n}\n\n// Same base-URL resolution as sitemap.ts/robots.ts: env override first, then\n// config.json. Without either, feed links degrade to root-relative paths.\nfunction resolveBaseUrl(): string | null {\n const raw = process.env.NEXT_PUBLIC_SITE_URL ?? config.url;\n if (!raw) return null;\n return raw.replace(/\\/$/, \"\");\n}\n\n// Ampersand first, or it would re-escape the other entities.\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\");\n}\n\n// Builds the RSS 2.0 document for a page's subscribable changelog. Entry\n// descriptions arrive as pure Markdown (components, code, and HTML were\n// removed at generation time) and are entity-escaped here, so no CDATA\n// sections are needed. Entries carry no pubDate: the guid is the entry's\n// permalink, so feed readers surface new entries when new guids appear.\nexport function buildRssFeed(feed: RssFeedData): string {\n const base = resolveBaseUrl() ?? \"\";\n // The homepage feed has an empty pagePath; joining through this prefix\n // keeps its URLs free of double slashes (\"//rss.xml\" would be read as a\n // protocol-relative URL).\n const pagePrefix = feed.pagePath ? `/${feed.pagePath}` : \"\";\n const pageUrl = `${base}${pagePrefix}` || \"/\";\n const feedUrl = `${base}${pagePrefix}/rss.xml`;\n const siteName = config.name || \"Documentation\";\n const title = feed.title ?? siteName;\n const description = feed.description ?? config.description ?? title;\n\n const items = feed.items.map((item) => {\n const link = `${pageUrl}#${item.anchor}`;\n return [\n \" <item>\",\n ` <title>${escapeXml(item.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(item.description)}</description>`,\n \" </item>\",\n ].join(\"\\n\");\n });\n\n return [\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>`,\n `<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">`,\n \" <channel>\",\n ` <title>${escapeXml(title)}</title>`,\n ` <link>${escapeXml(pageUrl)}</link>`,\n ` <description>${escapeXml(description)}</description>`,\n ` <atom:link href=\"${escapeXml(feedUrl)}\" rel=\"self\" type=\"application/rss+xml\" />`,\n ` <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>`,\n ` <copyright>${escapeXml(siteName)}</copyright>`,\n ...items,\n \" </channel>\",\n \"</rss>\",\n \"\",\n ].join(\"\\n\");\n}\n";
@@ -8,6 +8,7 @@ export interface RssItem {
8
8
 
9
9
  export interface RssFeedData {
10
10
  // Page path relative to the site root, e.g. "update" or "guides/setup".
11
+ // Empty string means the homepage feed (served from /rss.xml).
11
12
  pagePath: string;
12
13
  // Channel title; null falls back to the site name from config.json.
13
14
  title: string | null;
@@ -40,9 +41,13 @@ function escapeXml(text: string): string {
40
41
  // sections are needed. Entries carry no pubDate: the guid is the entry's
41
42
  // permalink, so feed readers surface new entries when new guids appear.
42
43
  export function buildRssFeed(feed: RssFeedData): string {
43
- const base = resolveBaseUrl();
44
- const pageUrl = base ? \`\${base}/\${feed.pagePath}\` : \`/\${feed.pagePath}\`;
45
- const feedUrl = \`\${pageUrl}/rss.xml\`;
44
+ const base = resolveBaseUrl() ?? "";
45
+ // The homepage feed has an empty pagePath; joining through this prefix
46
+ // keeps its URLs free of double slashes ("//rss.xml" would be read as a
47
+ // protocol-relative URL).
48
+ const pagePrefix = feed.pagePath ? \`/\${feed.pagePath}\` : "";
49
+ const pageUrl = \`\${base}\${pagePrefix}\` || "/";
50
+ const feedUrl = \`\${base}\${pagePrefix}/rss.xml\`;
46
51
  const siteName = config.name || "Documentation";
47
52
  const title = feed.title ?? siteName;
48
53
  const description = feed.description ?? config.description ?? title;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doccupine",
3
- "version": "0.0.135",
3
+ "version": "0.0.136",
4
4
  "description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {