@publish.os/nextjs 0.0.1-alpha.6 → 0.0.1-alpha.7

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.
Files changed (220) hide show
  1. package/README.md +3 -5
  2. package/compiler-assets/nextjs/defaults/app/globals.css +6 -0
  3. package/compiler-assets/nextjs/defaults/group/layout.tsx +23 -0
  4. package/compiler-assets/nextjs/defaults/group/leaf.tsx +48 -0
  5. package/compiler-assets/nextjs/defaults/group/page.tsx +50 -0
  6. package/compiler-assets/nextjs/defaults/project/next.config.mjs +45 -0
  7. package/compiler-assets/nextjs/defaults/project/postcss.config.mjs +5 -0
  8. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +41 -0
  9. package/compiler-assets/nextjs/defaults/root/css/animation.css +90 -0
  10. package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +21 -0
  11. package/compiler-assets/nextjs/defaults/root/css/components/drawer.css +21 -0
  12. package/compiler-assets/nextjs/defaults/root/css/components/menu.css +23 -0
  13. package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +25 -0
  14. package/compiler-assets/nextjs/defaults/root/css/components/popover.css +17 -0
  15. package/compiler-assets/nextjs/defaults/root/css/components/select.css +23 -0
  16. package/compiler-assets/nextjs/defaults/root/css/components/toast.css +19 -0
  17. package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +15 -0
  18. package/compiler-assets/nextjs/defaults/root/css/layout.css +22 -0
  19. package/compiler-assets/nextjs/defaults/root/css/media.css +81 -0
  20. package/compiler-assets/nextjs/defaults/root/css/radius.css +49 -0
  21. package/compiler-assets/nextjs/defaults/root/css/scrollbar.css +43 -0
  22. package/compiler-assets/nextjs/defaults/root/css/shadow.css +145 -0
  23. package/compiler-assets/nextjs/defaults/root/css/typography.css +607 -0
  24. package/compiler-assets/nextjs/defaults/root/css/zindex.css +39 -0
  25. package/compiler-assets/nextjs/defaults/root/globals.css +191 -0
  26. package/compiler-assets/nextjs/defaults/root/layout.tsx +19 -0
  27. package/compiler-assets/nextjs/defaults/root/page.tsx +61 -0
  28. package/compiler-assets/nextjs/defaults/root/theme.css +50 -0
  29. package/compiler-assets/nextjs/defaults/source/_internal/logger.ts +21 -0
  30. package/compiler-assets/nextjs/shims/generated-group-layout.tsx +19 -0
  31. package/compiler-assets/nextjs/shims/generated-group-page.tsx +18 -0
  32. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +21 -0
  33. package/compiler-assets/nextjs/shims/global-layout.tsx +134 -0
  34. package/compiler-assets/nextjs/shims/markdown-route.ts +29 -0
  35. package/compiler-assets/nextjs/shims/og-image-route.ts +18 -0
  36. package/compiler-assets/nextjs/shims/powered-by-footer.tsx +40 -0
  37. package/compiler-assets/nextjs/shims/providers.tsx +13 -0
  38. package/compiler-assets/nextjs/shims/proxy.ts +317 -0
  39. package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +77 -0
  40. package/compiler-assets/nextjs/shims/root-page.tsx +13 -0
  41. package/compiler-assets/nextjs/shims/theme-defaults.css +177 -0
  42. package/dist/button-CFdx-ohV.d.ts +20 -0
  43. package/dist/cache/tags.js +6 -14
  44. package/dist/compiler.d.ts +100 -0
  45. package/dist/compiler.js +13379 -0
  46. package/dist/config/createNextConfig.d.ts +2 -1
  47. package/dist/config/createNextConfig.js +16 -12
  48. package/dist/icons.d.ts +1 -0
  49. package/dist/icons.js +2 -0
  50. package/dist/index.d.ts +303 -15
  51. package/dist/index.js +30 -1198
  52. package/dist/kernel/components/blocks/AgentActions.d.ts +9 -3
  53. package/dist/kernel/components/blocks/AgentActions.js +114 -200
  54. package/dist/kernel/components/blocks/animated-icon-swap.js +4 -25
  55. package/dist/kernel/components/blocks/color-palette.js +88 -169
  56. package/dist/kernel/components/blocks/design-system-preview.d.ts +38 -6
  57. package/dist/kernel/components/blocks/design-system-preview.js +44 -52
  58. package/dist/kernel/components/blocks/link-playground.js +23 -71
  59. package/dist/kernel/components/blocks/logo-block.js +18 -47
  60. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +1 -1
  61. package/dist/kernel/components/blocks/nav-breadcrumb.js +28 -42
  62. package/dist/kernel/components/blocks/navbar.d.ts +1 -1
  63. package/dist/kernel/components/blocks/navbar.js +14 -41
  64. package/dist/kernel/components/blocks/navigation-progress-playground.js +56 -149
  65. package/dist/kernel/components/blocks/navigation-progress.js +53 -157
  66. package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
  67. package/dist/kernel/components/blocks/next-prev.js +16 -42
  68. package/dist/kernel/components/blocks/page-list.d.ts +1 -1
  69. package/dist/kernel/components/blocks/page-list.js +11 -16
  70. package/dist/kernel/components/blocks/search.d.ts +13 -2
  71. package/dist/kernel/components/blocks/search.js +116 -247
  72. package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
  73. package/dist/kernel/components/blocks/sidebar-node.js +56 -95
  74. package/dist/kernel/components/blocks/sidebar.d.ts +5 -23
  75. package/dist/kernel/components/blocks/sidebar.js +35 -103
  76. package/dist/kernel/components/blocks/theme-toggle.d.ts +7 -3
  77. package/dist/kernel/components/blocks/theme-toggle.js +2 -2
  78. package/dist/kernel/components/blocks/toc.js +42 -178
  79. package/dist/kernel/components/mdx/components/blockquote.js +3 -24
  80. package/dist/kernel/components/mdx/components/callout.d.ts +1 -1
  81. package/dist/kernel/components/mdx/components/callout.js +15 -47
  82. package/dist/kernel/components/mdx/components/code-block.js +2 -2
  83. package/dist/kernel/components/mdx/components/figure-caption.js +6 -24
  84. package/dist/kernel/components/mdx/components/figure.js +9 -36
  85. package/dist/kernel/components/mdx/components/footnotes.js +3 -24
  86. package/dist/kernel/components/mdx/components/heading-copy-link.js +13 -37
  87. package/dist/kernel/components/mdx/components/heading.d.ts +8 -3
  88. package/dist/kernel/components/mdx/components/heading.js +32 -116
  89. package/dist/kernel/components/mdx/components/hr.d.ts +5 -3
  90. package/dist/kernel/components/mdx/components/hr.js +2 -2
  91. package/dist/kernel/components/mdx/components/image-zoom.js +2 -3
  92. package/dist/kernel/components/mdx/components/image.js +22 -62
  93. package/dist/kernel/components/mdx/components/inline-code.js +3 -24
  94. package/dist/kernel/components/mdx/components/kbd.d.ts +9 -4
  95. package/dist/kernel/components/mdx/components/kbd.js +2 -2
  96. package/dist/kernel/components/mdx/components/link.d.ts +1 -2
  97. package/dist/kernel/components/mdx/components/link.js +2 -2
  98. package/dist/kernel/components/mdx/components/paragraph.js +13 -41
  99. package/dist/kernel/components/mdx/components/pre.js +3 -24
  100. package/dist/kernel/components/mdx/components/strikethrough.js +6 -24
  101. package/dist/kernel/components/mdx/components/table.js +2 -2
  102. package/dist/kernel/components/mdx/components/task-list.js +6 -28
  103. package/dist/kernel/components/mdx/components/video-player.js +53 -88
  104. package/dist/kernel/components/mdx/components/video.js +27 -75
  105. package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
  106. package/dist/kernel/components/mdx/error-boundary.js +12 -15
  107. package/dist/kernel/components/mdx/error-fallback.js +4 -4
  108. package/dist/kernel/components/mdx/mdx.d.ts +68 -11
  109. package/dist/kernel/components/mdx/mdx.js +29 -29
  110. package/dist/kernel/components/mdx/rehype-heading-ids.js +11 -67
  111. package/dist/kernel/components/mdx/types.d.ts +1 -1
  112. package/dist/kernel/components/ui/accordion.js +3 -26
  113. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +23 -7
  114. package/dist/kernel/components/ui/breadcrumb-trail.js +32 -80
  115. package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
  116. package/dist/kernel/components/ui/breadcrumb.js +20 -54
  117. package/dist/kernel/components/ui/button-group.d.ts +4 -3
  118. package/dist/kernel/components/ui/button-group.js +7 -30
  119. package/dist/kernel/components/ui/button.js +13 -36
  120. package/dist/kernel/components/ui/card.d.ts +2 -2
  121. package/dist/kernel/components/ui/card.js +2 -23
  122. package/dist/kernel/components/ui/dialog.d.ts +9 -9
  123. package/dist/kernel/components/ui/dialog.js +15 -33
  124. package/dist/kernel/components/ui/drawer.d.ts +10 -10
  125. package/dist/kernel/components/ui/drawer.js +15 -33
  126. package/dist/kernel/components/ui/input.js +6 -30
  127. package/dist/kernel/components/ui/kbd.js +10 -31
  128. package/dist/kernel/components/ui/link.d.ts +1 -1
  129. package/dist/kernel/components/ui/link.js +53 -104
  130. package/dist/kernel/components/ui/menu.d.ts +21 -21
  131. package/dist/kernel/components/ui/menu.js +10 -32
  132. package/dist/kernel/components/ui/meta-key.d.ts +9 -4
  133. package/dist/kernel/components/ui/meta-key.js +2 -2
  134. package/dist/kernel/components/ui/navigation-menu.d.ts +14 -14
  135. package/dist/kernel/components/ui/navigation-menu.js +9 -30
  136. package/dist/kernel/components/ui/popover.d.ts +10 -10
  137. package/dist/kernel/components/ui/popover.js +19 -34
  138. package/dist/kernel/components/ui/progress.js +2 -25
  139. package/dist/kernel/components/ui/scroll-area.js +39 -118
  140. package/dist/kernel/components/ui/select.d.ts +15 -15
  141. package/dist/kernel/components/ui/select.js +19 -35
  142. package/dist/kernel/components/ui/separator.js +2 -25
  143. package/dist/kernel/components/ui/table.js +2 -23
  144. package/dist/kernel/components/ui/tabs.js +39 -99
  145. package/dist/kernel/components/ui/tag.d.ts +2 -2
  146. package/dist/kernel/components/ui/tag.js +4 -25
  147. package/dist/kernel/components/ui/text.d.ts +2 -2
  148. package/dist/kernel/components/ui/text.js +3 -25
  149. package/dist/kernel/components/ui/theme-toggle.d.ts +18 -4
  150. package/dist/kernel/components/ui/theme-toggle.js +18 -44
  151. package/dist/kernel/components/ui/toast.d.ts +10 -10
  152. package/dist/kernel/components/ui/toast.js +13 -35
  153. package/dist/kernel/components/ui/tooltip.d.ts +8 -8
  154. package/dist/kernel/components/ui/tooltip.js +8 -29
  155. package/dist/kernel/defaults.registry.d.ts +1 -1
  156. package/dist/kernel/defaults.registry.js +2 -2
  157. package/dist/kernel/framework-icons.d.ts +1 -0
  158. package/dist/kernel/framework-icons.js +39 -0
  159. package/dist/kernel/routes/agent/markdown.js +36 -65
  160. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  161. package/dist/kernel/routes/layouts/group.js +20 -109
  162. package/dist/kernel/routes/metadata/feed.d.ts +1 -2
  163. package/dist/kernel/routes/metadata/feed.js +46 -127
  164. package/dist/kernel/routes/metadata/llms.d.ts +1 -2
  165. package/dist/kernel/routes/metadata/llms.js +40 -120
  166. package/dist/kernel/routes/metadata/og-image.d.ts +10 -0
  167. package/dist/kernel/routes/metadata/og-image.js +264 -198
  168. package/dist/kernel/routes/metadata/robots.d.ts +1 -2
  169. package/dist/kernel/routes/metadata/robots.js +21 -90
  170. package/dist/kernel/routes/metadata/sitemap.d.ts +1 -2
  171. package/dist/kernel/routes/metadata/sitemap.js +36 -102
  172. package/dist/kernel/routes/pages/group.d.ts +1 -1
  173. package/dist/kernel/routes/pages/group.js +42 -137
  174. package/dist/kernel/routes/pages/leaf.d.ts +1 -1
  175. package/dist/kernel/routes/pages/leaf.js +74 -213
  176. package/dist/kernel/routes/pages/root.d.ts +1 -1
  177. package/dist/kernel/routes/pages/root.js +37 -108
  178. package/dist/keyboard-shortcuts.js +69 -141
  179. package/dist/link-CYaCRDb6.d.ts +35 -0
  180. package/dist/resolvers/manifest-resolver.d.ts +3 -3
  181. package/dist/resolvers/manifest-resolver.js +15 -21
  182. package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
  183. package/dist/search.d.ts +81 -4
  184. package/dist/search.js +124 -195
  185. package/dist/sidebar-types-Bgchdfd6.d.ts +25 -0
  186. package/dist/theme-scope.d.ts +15 -0
  187. package/dist/theme-scope.js +23 -0
  188. package/dist/types-B_b3C0U6.d.ts +63 -0
  189. package/dist/types-CIwwieNw.d.ts +127 -0
  190. package/dist/types-DHBm7-j6.d.ts +57 -0
  191. package/dist/types-sM2g9nW0.d.ts +12 -0
  192. package/dist/types.d.ts +0 -1
  193. package/dist/types.js +1 -1
  194. package/dist/utils/cn.d.ts +5 -9
  195. package/dist/utils/cn.js +13 -7
  196. package/dist/utils/heading-ids.js +20 -47
  197. package/dist/utils/pretty-date.js +7 -13
  198. package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.dark.png +0 -0
  199. package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.png +0 -0
  200. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +54 -0
  201. package/init/seed/minimal/publish.os/docs/content/groups.mdx +31 -0
  202. package/init/seed/minimal/publish.os/docs/content/theme.mdx +64 -0
  203. package/init/seed/minimal/publish.os/publish.os.config.json +21 -0
  204. package/init/seed/minimal/publish.os/theme.css +47 -0
  205. package/init/seed/minimal/seed.json +13 -0
  206. package/package.json +469 -35
  207. package/release/{package.json → app/lucide/package.json} +11 -5
  208. package/release/app/lucide/pnpm-lock.yaml.template +2905 -0
  209. package/release/app/lucide/pnpm-workspace.yaml +11 -0
  210. package/release/app/phosphor/package.json +30 -0
  211. package/release/app/phosphor/pnpm-lock.yaml.template +2908 -0
  212. package/release/app/phosphor/pnpm-workspace.yaml +11 -0
  213. package/release/app/tabler/package.json +30 -0
  214. package/release/app/tabler/pnpm-lock.yaml.template +2911 -0
  215. package/release/app/tabler/pnpm-workspace.yaml +11 -0
  216. package/release/compiler/package.json +20 -0
  217. package/release/compiler/pnpm-lock.yaml.template +2432 -0
  218. package/release/compiler/pnpm-workspace.yaml +11 -0
  219. package/release/release.json +29 -5
  220. package/release/runtime-pnpm-lock.yaml +0 -1316
package/dist/index.js CHANGED
@@ -1,1201 +1,33 @@
1
- // src/cache/tags.ts
2
- import { createHash } from "crypto";
3
- var MAX_TAG_LEN = 256;
4
- var MAX_SEGMENT_LEN = 80;
5
- var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
6
- function sha256(value) {
7
- return createHash("sha256").update(value).digest("hex").slice(0, 16);
8
- }
9
- function safeSegment(value) {
10
- const raw = value.trim().toLowerCase() || "root";
11
- const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
12
- const segment = normalized || "root";
13
- if (segment.length <= MAX_SEGMENT_LEN) return segment;
14
- return `${segment.slice(0, 48)}.${sha256(segment)}`;
15
- }
16
- function assertTag(tag) {
17
- if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
18
- return `tag:${sha256(tag)}`;
19
- }
20
- return tag;
21
- }
22
- var tags = {
23
- site() {
24
- return "site";
25
- },
26
- pages() {
27
- return "pages";
28
- },
29
- group(group) {
30
- return assertTag(`group:${safeSegment(group)}`);
31
- },
32
- page(group, slug) {
33
- const path = Array.isArray(slug) ? slug.join("/") : slug;
34
- return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
35
- },
36
- manifest(contentHash) {
37
- return assertTag(`manifest:${safeSegment(contentHash)}`);
38
- },
39
- sitemap() {
40
- return "sitemap";
41
- },
42
- robots() {
43
- return "robots";
44
- },
45
- llms(scope = "root") {
46
- return assertTag(`llms:${safeSegment(scope)}`);
47
- },
48
- feed(format, scope = "site") {
49
- return assertTag(`feed:${safeSegment(format)}:${safeSegment(scope)}`);
50
- }
51
- };
52
-
53
- // src/config/createNextConfig.ts
54
- function createNextConfig(_options) {
55
- return {
56
- transpilePackages: ["@publish.os/nextjs"],
57
- cacheComponents: true,
58
- cacheLife: {
59
- page: {
60
- stale: 60 * 5,
61
- revalidate: 60 * 60,
62
- expire: 60 * 60 * 24
63
- },
64
- feed: {
65
- stale: 60 * 60,
66
- revalidate: 60 * 60 * 6,
67
- expire: 60 * 60 * 24 * 7
68
- },
69
- sitemap: {
70
- stale: 60 * 60,
71
- revalidate: 60 * 60 * 24,
72
- expire: 60 * 60 * 24 * 30
73
- }
74
- }
75
- };
76
- }
77
-
78
- // src/kernel/components/blocks/page-list.tsx
79
- import { Link } from "../ui/link.js";
80
- import { jsx } from "react/jsx-runtime";
81
- function pageNodes(nodes) {
82
- return nodes.flatMap((node) => {
83
- if (node.type === "page") return [node];
84
- if (node.type === "section" || node.type === "folder") {
85
- return pageNodes(node.children);
86
- }
87
- return [];
88
- });
89
- }
90
- function PageList({ tree, currentPath, className }) {
91
- const pages = pageNodes(tree);
92
- if (pages.length === 0) {
93
- return null;
94
- }
95
- return /* @__PURE__ */ jsx("nav", { "aria-label": "Pages in this group", className, children: /* @__PURE__ */ jsx("ul", { className: "space-y-2 text-sm", children: pages.map((page) => {
96
- const active = page.path === currentPath;
97
- return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
98
- Link,
99
- {
100
- active,
101
- color: active ? "accent" : "default",
102
- href: page.path,
103
- size: "sm",
104
- children: page.title
105
- }
106
- ) }, `${page.group}:${page.fileID}`);
107
- }) }) });
108
- }
109
-
110
- // src/kernel/routes/metadata/feed.ts
111
- import { cacheLife, cacheTag } from "next/cache";
112
-
113
- // src/kernel/routes/response.ts
114
- var CACHE_CONTROL = "public, max-age=300, s-maxage=3600, stale-while-revalidate=3600, must-revalidate";
115
- var CDN_CACHE_CONTROL = "public, max-age=3600, stale-while-revalidate=3600, must-revalidate";
116
- var SHORT_CACHE_CONTROL = "public, max-age=60, s-maxage=600, stale-while-revalidate=300, must-revalidate";
117
- var SHORT_CDN_CACHE_CONTROL = "public, max-age=300, stale-while-revalidate=3600";
118
- function cacheControl(policy) {
119
- if (!policy || policy === "default") return CACHE_CONTROL;
120
- if (policy === "short") return SHORT_CACHE_CONTROL;
121
- return policy;
122
- }
123
- function cdnCacheControl(policy) {
124
- if (!policy || policy === "default") return CDN_CACHE_CONTROL;
125
- if (policy === "short") return SHORT_CDN_CACHE_CONTROL;
126
- return policy;
127
- }
128
- function cachedTextHeaders(contentType, options = {}) {
129
- const headers = new Headers(options.headers);
130
- headers.set("cache-control", cacheControl(options.cachePolicy));
131
- headers.set("cdn-cache-control", cdnCacheControl(options.cachePolicy));
132
- headers.set("vercel-cdn-cache-control", cdnCacheControl(options.cachePolicy));
133
- headers.set("content-type", contentType);
134
- headers.set("x-content-type-options", "nosniff");
135
- if (options.noindex) headers.set("x-robots-tag", "noindex");
136
- return headers;
137
- }
138
- function createCachedTextResponse(options) {
139
- const status = options.status ?? 200;
140
- const method = options.method ?? "GET";
141
- const headers = cachedTextHeaders(options.contentType, options);
142
- return new Response(method === "HEAD" ? null : options.body, {
143
- headers,
144
- status
145
- });
146
- }
147
-
148
- // src/kernel/routes/metadata/canonical-url.ts
149
- function canonicalUrl(manifest, path) {
150
- const origin = manifest.site.url?.replace(/\/+$/, "");
151
- if (!origin) return path;
152
- try {
153
- return new URL(path, `${origin}/`).toString();
154
- } catch {
155
- return path;
156
- }
157
- }
158
-
159
- // src/kernel/routes/metadata/feed.ts
160
- function xmlEscape(value) {
161
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
162
- }
163
- function pageTimestamp(page) {
164
- const value = page.publishedAt ?? page.updatedAt;
165
- if (!value) return -Infinity;
166
- const timestamp = Date.parse(value);
167
- return Number.isNaN(timestamp) ? -Infinity : timestamp;
168
- }
169
- function pageInScope(page, options) {
170
- if (options.scope === "site" || !options.group) return true;
171
- if (options.scope === "self") return page.group === options.group;
172
- return page.group === options.group || page.group.startsWith(`${options.group}/`);
173
- }
174
- function feedPages(manifest, options) {
175
- const statuses = options.status ?? ["published"];
176
- const pages = manifest.pages.filter((page) => statuses.includes(page.status)).filter((page) => pageInScope(page, options)).sort((a, b) => pageTimestamp(b) - pageTimestamp(a));
177
- return options.limit ? pages.slice(0, options.limit) : pages;
178
- }
179
- async function rssXml(manifest, options = {}) {
180
- "use cache";
181
- cacheLife("page");
182
- cacheTag(
183
- tags.site(),
184
- tags.feed("rss", options.group ?? options.scope ?? "site"),
185
- tags.manifest(manifest.contentHash)
186
- );
187
- const title = manifest.site.name;
188
- const description = manifest.site.description ?? title;
189
- const pages = feedPages(manifest, options);
190
- const homeUrl = canonicalUrl(manifest, "/");
191
- const items = pages.map((page) => {
192
- const pageUrl = canonicalUrl(manifest, page.path);
193
- const pubDate = page.publishedAt ? `
194
- <pubDate>${xmlEscape(new Date(page.publishedAt).toUTCString())}</pubDate>` : "";
195
- const description2 = page.description ? `
196
- <description>${xmlEscape(page.description)}</description>` : "";
197
- return ` <item>
198
- <title>${xmlEscape(page.title)}</title>
199
- <link>${xmlEscape(pageUrl)}</link>
200
- <guid>${xmlEscape(pageUrl)}</guid>${pubDate}${description2}
201
- </item>`;
202
- }).join("\n");
203
- return `<?xml version="1.0" encoding="UTF-8"?>
204
- <rss version="2.0">
205
- <channel>
206
- <title>${xmlEscape(title)}</title>
207
- <link>${xmlEscape(homeUrl)}</link>
208
- <description>${xmlEscape(description)}</description>
209
- ${items}
210
- </channel>
211
- </rss>
212
- `;
213
- }
214
- function pageDate(page) {
215
- return page.publishedAt ?? page.updatedAt;
216
- }
217
- function latestFeedDate(pages) {
218
- const timestamp = Math.max(0, ...pages.map((page) => pageTimestamp(page)));
219
- return new Date(timestamp).toISOString();
220
- }
221
- async function atomXml(manifest, options = {}) {
222
- "use cache";
223
- cacheLife("page");
224
- cacheTag(
225
- tags.site(),
226
- tags.feed("atom", options.group ?? options.scope ?? "site"),
227
- tags.manifest(manifest.contentHash)
228
- );
229
- const title = manifest.site.name;
230
- const pages = feedPages(manifest, options);
231
- const homeUrl = canonicalUrl(manifest, "/");
232
- const entries = pages.map((page) => {
233
- const date = pageDate(page);
234
- const updated = date ? new Date(date).toISOString() : latestFeedDate([]);
235
- const pageUrl = canonicalUrl(manifest, page.path);
236
- const summary = page.description ? `
237
- <summary>${xmlEscape(page.description)}</summary>` : "";
238
- return ` <entry>
239
- <title>${xmlEscape(page.title)}</title>
240
- <id>${xmlEscape(pageUrl)}</id>
241
- <link href="${xmlEscape(pageUrl)}" />
242
- <updated>${xmlEscape(updated)}</updated>${summary}
243
- </entry>`;
244
- }).join("\n");
245
- return `<?xml version="1.0" encoding="UTF-8"?>
246
- <feed xmlns="http://www.w3.org/2005/Atom">
247
- <title>${xmlEscape(title)}</title>
248
- <id>${xmlEscape(homeUrl)}</id>
249
- <updated>${xmlEscape(latestFeedDate(pages))}</updated>
250
- ${entries}
251
- </feed>
252
- `;
253
- }
254
- async function jsonFeed(manifest, options = {}) {
255
- "use cache";
256
- cacheLife("page");
257
- cacheTag(
258
- tags.site(),
259
- tags.feed("json", options.group ?? options.scope ?? "site"),
260
- tags.manifest(manifest.contentHash)
261
- );
262
- const pages = feedPages(manifest, options);
263
- return `${JSON.stringify(
264
- {
265
- version: "https://jsonfeed.org/version/1.1",
266
- title: manifest.site.name,
267
- description: manifest.site.description,
268
- home_page_url: canonicalUrl(manifest, "/"),
269
- items: pages.map((page) => ({
270
- id: canonicalUrl(manifest, page.path),
271
- url: canonicalUrl(manifest, page.path),
272
- title: page.title,
273
- summary: page.description,
274
- content_text: page.body,
275
- date_published: page.publishedAt,
276
- date_modified: page.updatedAt,
277
- tags: page.tags
278
- }))
279
- },
280
- null,
281
- 2
282
- )}
283
- `;
284
- }
285
- function createRssFeedRoute(manifest, options = {}) {
286
- return async function GET() {
287
- return createCachedTextResponse({
288
- body: await rssXml(manifest, options),
289
- contentType: "application/rss+xml; charset=utf-8"
290
- });
291
- };
292
- }
293
- function createAtomFeedRoute(manifest, options = {}) {
294
- return async function GET() {
295
- return createCachedTextResponse({
296
- body: await atomXml(manifest, options),
297
- contentType: "application/atom+xml; charset=utf-8"
298
- });
299
- };
300
- }
301
- function createJsonFeedRoute(manifest, options = {}) {
302
- return async function GET() {
303
- return createCachedTextResponse({
304
- body: await jsonFeed(manifest, options),
305
- contentType: "application/feed+json; charset=utf-8"
306
- });
307
- };
308
- }
309
-
310
- // src/kernel/routes/metadata/llms.ts
311
- import { cacheLife as cacheLife2, cacheTag as cacheTag2 } from "next/cache";
312
- var TEXT_ENCODER = new TextEncoder();
313
- function pageInScope2(page, options) {
314
- if (options.scope === "site" || !options.group) return true;
315
- if (options.scope === "self") return page.group === options.group;
316
- return page.group === options.group || page.group.startsWith(`${options.group}/`);
317
- }
318
- function llmsSummary(manifest) {
319
- return manifest.site.description ? `> ${manifest.site.description}` : `> Agent-readable index for ${manifest.site.name}.`;
320
- }
321
- async function llmsTxt(manifest, options = {}) {
322
- "use cache";
323
- cacheLife2("page");
324
- cacheTag2(
325
- tags.site(),
326
- tags.llms(options.group ?? options.scope ?? "root"),
327
- tags.manifest(manifest.contentHash)
328
- );
329
- const pages = manifest.pages.filter((page) => page.status === "published").filter((page) => pageInScope2(page, options));
330
- const visiblePages = options.limit ? pages.slice(0, options.limit) : pages;
331
- const lines = visiblePages.map((page) => {
332
- const description = options.includeDescriptions && page.description ? ` - ${page.description}` : "";
333
- return `- [${page.title}](${canonicalUrl(manifest, page.path)})${description}`;
334
- });
335
- const linkLines = (options.links ?? []).map(
336
- (link) => `- [${link.title}](${canonicalUrl(manifest, link.path)})`
337
- );
338
- const linkSection = linkLines.length ? `
339
-
340
- ## Group LLM indexes
341
-
342
- ${linkLines.join("\n")}` : "";
343
- return `# ${manifest.site.name}
344
-
345
- ${llmsSummary(manifest)}
346
-
347
- ## Pages
348
-
349
- ${lines.join("\n")}${linkSection}
350
- `;
351
- }
352
- function createLlmsTxtRoute(manifest, options = {}) {
353
- return async function GET() {
354
- return createCachedTextResponse({
355
- body: await llmsTxt(manifest, options),
356
- contentType: "text/plain; charset=utf-8"
357
- });
358
- };
359
- }
360
-
361
- // src/kernel/routes/metadata/og-image.tsx
362
- import { readFile } from "fs/promises";
363
- import { createRequire } from "module";
364
- import { ImageResponse } from "next/og";
365
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
366
- var ERROR_HEADERS = {
367
- "cache-control": "public, max-age=60, must-revalidate",
368
- "cdn-cache-control": "public, max-age=300",
369
- "vercel-cdn-cache-control": "public, max-age=300",
370
- "x-content-type-options": "nosniff"
371
- };
372
- var SUCCESS_HEADERS = {
373
- "cache-control": "public, max-age=31536000, immutable",
374
- "cdn-cache-control": "public, max-age=31536000, immutable",
375
- "vercel-cdn-cache-control": "public, max-age=31536000, immutable",
376
- "x-content-type-options": "nosniff"
377
- };
378
- var DEVELOPMENT_SUCCESS_HEADERS = {
379
- "cache-control": "no-store",
380
- "cdn-cache-control": "no-store",
381
- "vercel-cdn-cache-control": "no-store",
382
- "x-content-type-options": "nosniff"
383
- };
384
- var KEY_PATTERN = /^[a-f0-9]{16}$/;
385
- var DESCRIPTION_MAX_LENGTH = 260;
386
- var LABEL_MAX_LENGTH = 72;
387
- var SITE_NAME_MAX_LENGTH = 42;
388
- var TITLE_MAX_LENGTH = 220;
389
- var GRID_INSET = 86;
390
- var GRID_BOTTOM = 544;
391
- var CONTENT_X = 122;
392
- var CONTENT_WIDTH = 956;
393
- var TITLE_MAX_FONT_SIZE = 60;
394
- var TITLE_MIN_FONT_SIZE = 40;
395
- var LOGO_MAX_WIDTH = 300;
396
- var LOGO_MAX_HEIGHT = 46;
397
- var MAX_RESPONSE_CACHE_ENTRIES = 128;
398
- var BADGE_RADIUS = 999;
399
- var CONTENT_TYPE_HEADER = { "content-type": "image/png" };
400
- var PLATFORM_FONT_FAMILY = "PublishOS Geist";
401
- var PLATFORM_FONT_WEIGHTS = [
402
- 400,
403
- 500,
404
- 600,
405
- 700,
406
- 800
407
- ];
408
- var fontArrayBufferCache = /* @__PURE__ */ new Map();
409
- var imageResponseFontCache = /* @__PURE__ */ new Map();
410
- var imageResponseCache = /* @__PURE__ */ new Map();
411
- var require2 = createRequire(`${process.cwd()}/package.json`);
412
- var platformFontPath = require2.resolve(
413
- "next/dist/compiled/@vercel/og/Geist-Regular.ttf"
414
- );
415
- var platformFontData;
416
- function isDevelopment() {
417
- return process.env.NODE_ENV === "development";
418
- }
419
- function successHeaders() {
420
- return isDevelopment() ? DEVELOPMENT_SUCCESS_HEADERS : SUCCESS_HEADERS;
421
- }
422
- function clampText(value, maxLength) {
423
- if (!value) return void 0;
424
- if (value.length <= maxLength) return value;
425
- return `${value.slice(0, maxLength - 3).trimEnd()}...`;
426
- }
427
- async function routeKey(context) {
428
- const params = await context.params;
429
- return params.key.replace(/\.png$/, "");
430
- }
431
- function ellipsize(value, maxLength) {
432
- if (value.length <= maxLength) return value;
433
- return `${value.slice(0, maxLength - 3).trimEnd()}...`;
434
- }
435
- function wrapText(options) {
436
- const source = clampText(options.text, options.maxLength);
437
- if (!source) return [];
438
- const maxCharsPerLine = Math.max(
439
- 12,
440
- Math.floor(options.width / (options.fontSize * 0.54))
441
- );
442
- const words = source.split(/\s+/).filter(Boolean);
443
- const lines = [];
444
- let line = "";
445
- for (const word of words) {
446
- const nextLine = line ? `${line} ${word}` : word;
447
- if (nextLine.length <= maxCharsPerLine) {
448
- line = nextLine;
449
- continue;
450
- }
451
- if (line) lines.push(line);
452
- line = word.length > maxCharsPerLine ? ellipsize(word, maxCharsPerLine) : word;
453
- if (lines.length === options.maxLines) break;
454
- }
455
- if (line && lines.length < options.maxLines) lines.push(line);
456
- const consumed = lines.join(" ").replace(/\.\.\.$/, "");
457
- const didOverflow = words.join(" ").length > consumed.length || (lines.at(-1)?.endsWith("...") ?? false);
458
- if (didOverflow && lines.length > 0) {
459
- const lastIndex = lines.length - 1;
460
- lines[lastIndex] = ellipsize(lines[lastIndex] ?? "", maxCharsPerLine);
461
- }
462
- return lines;
463
- }
464
- function singleLineText(options) {
465
- const source = clampText(options.text, options.maxLength);
466
- if (!source) return void 0;
467
- const charWidth = options.fontSize * (options.mono ? 0.62 : 0.54);
468
- const maxChars = Math.max(4, Math.floor(options.width / charWidth));
469
- return ellipsize(source.replace(/\s+/g, " "), maxChars);
470
- }
471
- function titleFontSize(title) {
472
- const length = title?.length ?? 0;
473
- if (length > 130) return TITLE_MIN_FONT_SIZE;
474
- if (length > 100) return 44;
475
- if (length > 80) return 48;
476
- if (length > 60) return 52;
477
- if (length > 40) return 56;
478
- return TITLE_MAX_FONT_SIZE;
479
- }
480
- function siteUrl(value) {
481
- if (!value) return void 0;
482
- const candidate = value.includes("://") ? value : `https://${value}`;
483
- try {
484
- return new URL(candidate);
485
- } catch {
486
- return void 0;
487
- }
488
- }
489
- function displayUrlParts(entry) {
490
- const url = siteUrl(entry.siteUrl);
491
- const host = url?.hostname ?? entry.siteUrl?.replace(/\/.*$/, "") ?? "";
492
- const basePath = url?.pathname.replace(/\/+$/, "") ?? "";
493
- const routePath = entry.routePath === "/" ? "" : `/${entry.routePath.replace(/^\/+/, "")}`;
494
- const path = `${basePath === "/" ? "" : basePath}${routePath}`;
495
- if (host) return { host, path };
496
- return { host: "", path: path || routePath };
497
- }
498
- function dataUrlToArrayBuffer(value) {
499
- const cached = fontArrayBufferCache.get(value);
500
- if (cached) return cached;
501
- const binary = atob(value);
502
- const bytes = new Uint8Array(binary.length);
503
- for (let index = 0; index < binary.length; index += 1) {
504
- bytes[index] = binary.charCodeAt(index);
505
- }
506
- fontArrayBufferCache.set(value, bytes.buffer);
507
- return bytes.buffer;
508
- }
509
- function platformFonts() {
510
- platformFontData ??= readFile(platformFontPath).then(
511
- (data) => data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)
512
- );
513
- return platformFontData.then(
514
- (data) => PLATFORM_FONT_WEIGHTS.map((weight) => ({
515
- data: data.slice(0),
516
- name: PLATFORM_FONT_FAMILY,
517
- style: "normal",
518
- weight
519
- }))
520
- );
521
- }
522
- async function imageResponseFonts(entry) {
523
- const cached = imageResponseFontCache.get(entry.key);
524
- if (cached) return cached;
525
- const manifestFonts = ["main", "mono"].flatMap((role) => {
526
- const font = entry.fonts?.[role];
527
- return font?.files?.map((file) => ({
528
- data: dataUrlToArrayBuffer(file.data),
529
- name: font.family,
530
- style: file.style,
531
- weight: file.weight
532
- })) ?? [];
533
- });
534
- const fonts = manifestFonts.length > 0 ? [...manifestFonts, ...await platformFonts()] : await platformFonts();
535
- imageResponseFontCache.set(entry.key, fonts);
536
- return fonts;
537
- }
538
- function fontFamily(font, fallback) {
539
- const fallbackStack = fallback === "mono" ? `"${PLATFORM_FONT_FAMILY}", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace` : `"${PLATFORM_FONT_FAMILY}", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;
540
- return font?.family ? `${JSON.stringify(font.family)}, ${fallbackStack}` : fallbackStack;
541
- }
542
- function fittedLogoDimensions(logo) {
543
- if (!logo?.width || !logo.height) return void 0;
544
- const scale = Math.min(
545
- LOGO_MAX_WIDTH / logo.width,
546
- LOGO_MAX_HEIGHT / logo.height,
547
- 1
548
- );
549
- return {
550
- height: Math.max(1, Math.round(logo.height * scale)),
551
- width: Math.max(1, Math.round(logo.width * scale))
552
- };
553
- }
554
- function cacheImageResponse(key, render) {
555
- if (isDevelopment()) return render();
556
- const cached = imageResponseCache.get(key);
557
- if (cached) return cached;
558
- const promise = render().catch((error) => {
559
- imageResponseCache.delete(key);
560
- throw error;
561
- });
562
- imageResponseCache.set(key, promise);
563
- if (imageResponseCache.size > MAX_RESPONSE_CACHE_ENTRIES) {
564
- const oldest = imageResponseCache.keys().next().value;
565
- if (oldest) imageResponseCache.delete(oldest);
566
- }
567
- return promise;
568
- }
569
- function responseFromCachedImage(cached) {
570
- return new Response(cached.body.slice(0), {
571
- headers: cached.headers,
572
- status: cached.status
573
- });
574
- }
575
- async function cachedImageResponse(response) {
576
- const headersToApply = successHeaders();
577
- const headers = new Headers(response.headers);
578
- headers.set("cache-control", headersToApply["cache-control"]);
579
- headers.set("cdn-cache-control", headersToApply["cdn-cache-control"]);
580
- headers.set(
581
- "vercel-cdn-cache-control",
582
- headersToApply["vercel-cdn-cache-control"]
583
- );
584
- headers.set(
585
- "x-content-type-options",
586
- headersToApply["x-content-type-options"]
587
- );
588
- if (!headers.has("content-type")) {
589
- headers.set("content-type", CONTENT_TYPE_HEADER["content-type"]);
590
- }
591
- return {
592
- body: await response.arrayBuffer(),
593
- headers,
594
- status: response.status
595
- };
596
- }
597
- function createOgImageRoute({ manifest }) {
598
- return async function GET(_request, context) {
599
- const key = await routeKey(context);
600
- if (!KEY_PATTERN.test(key)) {
601
- return new Response("Bad request", {
602
- headers: ERROR_HEADERS,
603
- status: 400
604
- });
605
- }
606
- const entry = manifest.generated[key];
607
- if (!entry || entry.source !== "generated") {
608
- return new Response("Not found", {
609
- headers: ERROR_HEADERS,
610
- status: 404
611
- });
612
- }
613
- const titleSize = titleFontSize(entry.title);
614
- const titleLines = wrapText({
615
- fontSize: titleSize,
616
- maxLength: TITLE_MAX_LENGTH,
617
- maxLines: 2,
618
- text: entry.title,
619
- width: 900
620
- });
621
- const descriptionLines = wrapText({
622
- fontSize: 30,
623
- maxLength: DESCRIPTION_MAX_LENGTH,
624
- maxLines: 2,
625
- text: entry.description,
626
- width: 870
627
- });
628
- const label = singleLineText({
629
- fontSize: 22,
630
- maxLength: LABEL_MAX_LENGTH,
631
- mono: true,
632
- text: entry.label,
633
- width: 520
634
- });
635
- const displayUrl = displayUrlParts(entry);
636
- const siteName = clampText(
637
- entry.siteName ?? entry.alt,
638
- SITE_NAME_MAX_LENGTH
639
- );
640
- const background = entry.background ?? "#ffffff";
641
- const textPrimary = entry.textPrimary ?? "#111111";
642
- const textSecondary = entry.textSecondary ?? "#525252";
643
- const accent = entry.accent ?? "#2563eb";
644
- const stroke = entry.stroke ?? "#e5e7eb";
645
- const logoSrc = entry.logo?.dataUri;
646
- const logoDimensions = fittedLogoDimensions(entry.logo);
647
- return responseFromCachedImage(
648
- await cacheImageResponse(
649
- entry.key,
650
- async () => cachedImageResponse(
651
- new ImageResponse(
652
- /* @__PURE__ */ jsxs(
653
- "div",
654
- {
655
- style: {
656
- background,
657
- color: textPrimary,
658
- display: "flex",
659
- fontFamily: fontFamily(entry.fonts?.main, "sans"),
660
- height: "100%",
661
- position: "relative",
662
- width: "100%"
663
- },
664
- children: [
665
- /* @__PURE__ */ jsx2(
666
- "div",
667
- {
668
- style: {
669
- background: stroke,
670
- display: "flex",
671
- height: "100%",
672
- left: GRID_INSET,
673
- position: "absolute",
674
- top: 0,
675
- width: 2
676
- }
677
- }
678
- ),
679
- /* @__PURE__ */ jsx2(
680
- "div",
681
- {
682
- style: {
683
- background: stroke,
684
- display: "flex",
685
- height: "100%",
686
- position: "absolute",
687
- right: GRID_INSET,
688
- top: 0,
689
- width: 2
690
- }
691
- }
692
- ),
693
- /* @__PURE__ */ jsx2(
694
- "div",
695
- {
696
- style: {
697
- background: stroke,
698
- display: "flex",
699
- height: 2,
700
- left: 0,
701
- position: "absolute",
702
- top: GRID_INSET,
703
- width: "100%"
704
- }
705
- }
706
- ),
707
- /* @__PURE__ */ jsx2(
708
- "div",
709
- {
710
- style: {
711
- background: stroke,
712
- bottom: GRID_INSET,
713
- display: "flex",
714
- height: 2,
715
- left: 0,
716
- position: "absolute",
717
- width: "100%"
718
- }
719
- }
720
- ),
721
- /* @__PURE__ */ jsx2(
722
- "div",
723
- {
724
- style: {
725
- alignItems: "center",
726
- color: accent,
727
- display: "flex",
728
- fontFamily: fontFamily(entry.fonts?.main, "sans"),
729
- fontSize: 22,
730
- fontWeight: 700,
731
- height: GRID_INSET,
732
- justifyContent: "flex-start",
733
- left: CONTENT_X,
734
- lineHeight: 1,
735
- overflow: "hidden",
736
- position: "absolute",
737
- top: 0,
738
- width: 430
739
- },
740
- children: logoSrc ? (
741
- // biome-ignore lint/performance/noImgElement: ImageResponse renders static manifest-provided logo data; next/image is not available in Satori output.
742
- /* @__PURE__ */ jsx2(
743
- "img",
744
- {
745
- alt: "",
746
- src: logoSrc,
747
- style: {
748
- height: logoDimensions?.height ?? LOGO_MAX_HEIGHT,
749
- maxHeight: LOGO_MAX_HEIGHT,
750
- maxWidth: LOGO_MAX_WIDTH,
751
- objectFit: "contain",
752
- objectPosition: "left center",
753
- width: logoDimensions?.width ?? "auto"
754
- }
755
- }
756
- )
757
- ) : siteName
758
- }
759
- ),
760
- label ? /* @__PURE__ */ jsx2(
761
- "div",
762
- {
763
- style: {
764
- alignItems: "center",
765
- display: "flex",
766
- fontFamily: fontFamily(entry.fonts?.mono, "mono"),
767
- height: GRID_INSET,
768
- justifyContent: "flex-end",
769
- overflow: "hidden",
770
- position: "absolute",
771
- right: CONTENT_X,
772
- top: 0,
773
- width: 520
774
- },
775
- children: /* @__PURE__ */ jsxs(
776
- "div",
777
- {
778
- style: {
779
- alignItems: "center",
780
- borderRadius: BADGE_RADIUS,
781
- color: accent,
782
- display: "flex",
783
- fontSize: 20,
784
- fontWeight: 600,
785
- lineHeight: 1,
786
- maxWidth: 520,
787
- overflow: "hidden",
788
- paddingBottom: 6,
789
- paddingLeft: 12,
790
- paddingRight: 12,
791
- paddingTop: 6,
792
- position: "relative"
793
- },
794
- children: [
795
- /* @__PURE__ */ jsx2(
796
- "div",
797
- {
798
- style: {
799
- background: accent,
800
- borderRadius: BADGE_RADIUS,
801
- bottom: 0,
802
- display: "flex",
803
- left: 0,
804
- opacity: 0.14,
805
- position: "absolute",
806
- right: 0,
807
- top: 0
808
- }
809
- }
810
- ),
811
- /* @__PURE__ */ jsx2(
812
- "div",
813
- {
814
- style: {
815
- borderColor: accent,
816
- borderRadius: BADGE_RADIUS,
817
- borderStyle: "solid",
818
- borderWidth: 1,
819
- bottom: 0,
820
- display: "flex",
821
- left: 0,
822
- opacity: 0.32,
823
- position: "absolute",
824
- right: 0,
825
- top: 0
826
- }
827
- }
828
- ),
829
- /* @__PURE__ */ jsx2("div", { style: { display: "flex", position: "relative" }, children: label })
830
- ]
831
- }
832
- )
833
- }
834
- ) : null,
835
- /* @__PURE__ */ jsxs(
836
- "div",
837
- {
838
- style: {
839
- display: "flex",
840
- flexDirection: "column",
841
- gap: 24,
842
- left: CONTENT_X,
843
- position: "absolute",
844
- top: 164,
845
- width: CONTENT_WIDTH
846
- },
847
- children: [
848
- /* @__PURE__ */ jsx2(
849
- "div",
850
- {
851
- style: {
852
- display: "flex",
853
- flexDirection: "column",
854
- fontSize: titleSize,
855
- fontWeight: 800,
856
- letterSpacing: 0,
857
- lineHeight: 1.08,
858
- width: 900
859
- },
860
- children: titleLines.map((line) => /* @__PURE__ */ jsx2("div", { style: { display: "flex" }, children: line }, line))
861
- }
862
- ),
863
- descriptionLines.length > 0 ? /* @__PURE__ */ jsx2(
864
- "div",
865
- {
866
- style: {
867
- color: textSecondary,
868
- display: "flex",
869
- flexDirection: "column",
870
- fontSize: 30,
871
- lineHeight: 1.25,
872
- width: 870
873
- },
874
- children: descriptionLines.map((line) => /* @__PURE__ */ jsx2("div", { style: { display: "flex" }, children: line }, line))
875
- }
876
- ) : null
877
- ]
878
- }
879
- ),
880
- /* @__PURE__ */ jsx2(
881
- "div",
882
- {
883
- style: {
884
- alignItems: "center",
885
- display: "flex",
886
- fontFamily: fontFamily(entry.fonts?.mono, "mono"),
887
- fontSize: 22,
888
- height: GRID_INSET,
889
- justifyContent: "flex-start",
890
- left: CONTENT_X,
891
- lineHeight: 1.2,
892
- overflow: "hidden",
893
- position: "absolute",
894
- top: GRID_BOTTOM,
895
- width: CONTENT_WIDTH
896
- },
897
- children: /* @__PURE__ */ jsxs(
898
- "div",
899
- {
900
- style: {
901
- display: "flex",
902
- flexDirection: "row",
903
- overflow: "hidden",
904
- textOverflow: "ellipsis",
905
- whiteSpace: "nowrap",
906
- width: CONTENT_WIDTH
907
- },
908
- children: [
909
- displayUrl.host ? /* @__PURE__ */ jsx2(
910
- "div",
911
- {
912
- style: {
913
- color: textSecondary,
914
- display: "flex",
915
- flexShrink: 0,
916
- whiteSpace: "nowrap"
917
- },
918
- children: displayUrl.host
919
- }
920
- ) : null,
921
- displayUrl.path ? /* @__PURE__ */ jsx2(
922
- "div",
923
- {
924
- style: {
925
- color: textPrimary,
926
- display: "flex",
927
- minWidth: 0,
928
- overflow: "hidden",
929
- textOverflow: "ellipsis",
930
- whiteSpace: "nowrap"
931
- },
932
- children: displayUrl.path
933
- }
934
- ) : null
935
- ]
936
- }
937
- )
938
- }
939
- )
940
- ]
941
- }
942
- ),
943
- {
944
- fonts: await imageResponseFonts(entry),
945
- headers: {
946
- ...CONTENT_TYPE_HEADER,
947
- ...successHeaders()
948
- },
949
- height: manifest.height,
950
- width: manifest.width
951
- }
952
- )
953
- )
954
- )
955
- );
956
- };
957
- }
958
- function createOgImageStaticParams({ manifest }) {
959
- return Object.keys(manifest.generated).map((key) => ({ key: `${key}.png` }));
960
- }
961
-
962
- // src/kernel/routes/metadata/robots.ts
963
- import { cacheLife as cacheLife3, cacheTag as cacheTag3 } from "next/cache";
964
- async function robotsTxt(manifest) {
965
- "use cache";
966
- cacheLife3("page");
967
- cacheTag3(tags.site(), tags.robots(), tags.manifest(manifest.contentHash));
968
- const sitemapUrl = canonicalUrl(manifest, "/sitemap.xml");
969
- return `User-agent: *
970
- Allow: /
971
- Sitemap: ${sitemapUrl}
972
- `;
973
- }
974
- function createRobotsTxtRoute(manifest) {
975
- return async function GET() {
976
- return createCachedTextResponse({
977
- body: await robotsTxt(manifest),
978
- contentType: "text/plain; charset=utf-8"
979
- });
980
- };
981
- }
982
-
983
- // src/kernel/routes/metadata/sitemap.ts
984
- import { cacheLife as cacheLife4, cacheTag as cacheTag4 } from "next/cache";
985
- function xmlEscape2(value) {
986
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
987
- }
988
- async function sitemapXml(manifest) {
989
- "use cache";
990
- cacheLife4("page");
991
- cacheTag4(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
992
- const urls = [
993
- "/",
994
- ...Object.values(manifest.groups).map((g) => g.path),
995
- ...manifest.pages.filter((page) => page.status === "published").map((page) => page.path)
996
- ];
997
- const uniqueUrls = [...new Set(urls)];
998
- const body = uniqueUrls.map(
999
- (url) => ` <url><loc>${xmlEscape2(canonicalUrl(manifest, url))}</loc></url>`
1000
- ).join("\n");
1001
- return `<?xml version="1.0" encoding="UTF-8"?>
1002
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
1003
- ${body}
1004
- </urlset>
1005
- `;
1006
- }
1007
- function createSitemapXmlRoute(manifest) {
1008
- return async function GET() {
1009
- return createCachedTextResponse({
1010
- body: await sitemapXml(manifest),
1011
- contentType: "application/xml; charset=utf-8"
1012
- });
1013
- };
1014
- }
1015
-
1016
- // src/resolvers/manifest-resolver.ts
1017
- function findNodeInTree(nodes, id) {
1018
- for (const node of nodes) {
1019
- if (node.type === "page") {
1020
- if (node.fileID === id) return node;
1021
- } else if (node.id === id) {
1022
- return node;
1023
- }
1024
- if (node.type === "section" || node.type === "folder") {
1025
- const found = findNodeInTree(node.children, id);
1026
- if (found) return found;
1027
- }
1028
- }
1029
- return null;
1030
- }
1031
- function pageNode(page) {
1032
- return {
1033
- type: "page",
1034
- fileID: page.fileID,
1035
- title: page.title,
1036
- path: page.path,
1037
- group: page.group,
1038
- description: page.description,
1039
- status: page.status,
1040
- publishedAt: page.publishedAt,
1041
- updatedAt: page.updatedAt,
1042
- authors: page.authors,
1043
- tags: page.tags,
1044
- meta: page.meta
1045
- };
1046
- }
1047
- function groupNode(group) {
1048
- return {
1049
- type: "section",
1050
- id: group.key,
1051
- title: group.title,
1052
- path: group.path,
1053
- group: group.key,
1054
- children: group.tree
1055
- };
1056
- }
1057
- function resolveLeaf(manifest, group, slug) {
1058
- const slugPath = Array.isArray(slug) ? slug.join("/") : slug;
1059
- const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
1060
- if (!page) return null;
1061
- const groupData = manifest.groups[group];
1062
- if (!groupData) return null;
1063
- return {
1064
- site: manifest.site,
1065
- tree: groupData.tree,
1066
- node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(page),
1067
- page,
1068
- currentPath: page.path,
1069
- group
1070
- };
1071
- }
1072
- function resolveGroup(manifest, group) {
1073
- const groupData = manifest.groups[group];
1074
- if (!groupData) return null;
1075
- return {
1076
- site: manifest.site,
1077
- tree: groupData.tree,
1078
- node: groupNode(groupData),
1079
- currentPath: groupData.path,
1080
- group
1081
- };
1082
- }
1083
- function resolveGroupLayout(manifest, group, children) {
1084
- const resolved = resolveGroup(manifest, group);
1085
- if (!resolved) return null;
1086
- return { ...resolved, children };
1087
- }
1088
- function listStaticParams(manifest, group) {
1089
- const groupData = manifest.groups[group];
1090
- if (!groupData) return [];
1091
- return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
1092
- }
1093
-
1094
- // src/utils/cn.ts
1095
- import { clsx } from "clsx";
1096
- import { extendTailwindMerge } from "tailwind-merge";
1097
- var twMerge = extendTailwindMerge({
1098
- extend: {
1099
- classGroups: {
1100
- z: [
1101
- "z-content",
1102
- "z-nav",
1103
- "z-overlay",
1104
- "z-modal",
1105
- "z-search",
1106
- "z-toast",
1107
- "z-progress"
1108
- ]
1109
- }
1110
- }
1111
- });
1112
- function cn(...inputs) {
1113
- return twMerge(clsx(inputs));
1114
- }
1115
-
1116
- // src/utils/heading-ids.ts
1117
- import { isValidElement } from "react";
1118
- var SELF_CLOSING_TAG_RE = new RegExp("<[^>]+/>", "g");
1119
- var PAIRED_TAG_RE = /<\/?\w[^>]*>/g;
1120
- var MDX_BOLD_RE = /\*\*(.*?)\*\*/g;
1121
- var MDX_ITALIC_RE = /\*(.*?)\*/g;
1122
- var MDX_UNDERLINE_BOLD_RE = /__(.*?)__/g;
1123
- var MDX_UNDERLINE_ITALIC_RE = /_(.*?)_/g;
1124
- var MDX_STRIKETHROUGH_RE = /~~(.*?)~~/g;
1125
- var MDX_INLINE_CODE_RE = /`(.*?)`/g;
1126
- var MDX_LINK_RE = /\[(.*?)\]\(.*?\)/g;
1127
- var NON_ALPHANUMERIC_RE = /[^a-z0-9]+/g;
1128
- var LEADING_TRAILING_HYPHEN_RE = /^-+|-+$/g;
1129
- var LEADING_DIGIT_RE = /^(\d)/;
1130
- var HEADING_RE = /^(#{1,6})[ \t]+(.+?)\s*#*\s*$/gm;
1131
- var FENCED_CODE_RE = /```[\s\S]*?```|~~~[\s\S]*?~~~/g;
1132
- function extractText(node) {
1133
- if (typeof node === "string") return node;
1134
- if (typeof node === "number") return String(node);
1135
- if (node == null || typeof node === "boolean") return "";
1136
- if (Array.isArray(node)) {
1137
- return node.map(extractText).join("");
1138
- }
1139
- if (isValidElement(node)) {
1140
- const element = node;
1141
- return element.props.children === void 0 ? "" : extractText(element.props.children);
1142
- }
1143
- return "";
1144
- }
1145
- function cleanHeadingText(input) {
1146
- const text = typeof input === "string" ? input : extractText(input);
1147
- return text.replace(SELF_CLOSING_TAG_RE, "").replace(PAIRED_TAG_RE, "").replace(MDX_BOLD_RE, "$1").replace(MDX_ITALIC_RE, "$1").replace(MDX_UNDERLINE_BOLD_RE, "$1").replace(MDX_UNDERLINE_ITALIC_RE, "$1").replace(MDX_STRIKETHROUGH_RE, "$1").replace(MDX_INLINE_CODE_RE, "$1").replace(MDX_LINK_RE, "$1").trim();
1148
- }
1149
- function slugify(text) {
1150
- return text.toLowerCase().replace(NON_ALPHANUMERIC_RE, "-").replace(LEADING_TRAILING_HYPHEN_RE, "").replace(LEADING_DIGIT_RE, "id-$1");
1151
- }
1152
- function headingToHTMLId(input) {
1153
- try {
1154
- const id = slugify(cleanHeadingText(input));
1155
- return id || "empty-heading";
1156
- } catch {
1157
- return "empty-heading";
1158
- }
1159
- }
1160
- function createHeadingIdGenerator() {
1161
- const usedIds = /* @__PURE__ */ new Map();
1162
- return (input) => {
1163
- const baseId = headingToHTMLId(input);
1164
- if (baseId === "empty-heading") return baseId;
1165
- const count = usedIds.get(baseId) ?? 0;
1166
- usedIds.set(baseId, count + 1);
1167
- return count === 0 ? baseId : `${baseId}-${count}`;
1168
- };
1169
- }
1170
- function extractMdxHeadings(content = "", levels) {
1171
- const [minDepth, maxDepth] = levels;
1172
- const headingId = createHeadingIdGenerator();
1173
- const headings = [];
1174
- const searchableContent = content.replace(FENCED_CODE_RE, "");
1175
- HEADING_RE.lastIndex = 0;
1176
- while (true) {
1177
- const match = HEADING_RE.exec(searchableContent);
1178
- if (!match) break;
1179
- const marker = match[1];
1180
- const rawText = match[2];
1181
- if (!marker || !rawText) continue;
1182
- const level = marker.length;
1183
- const text = cleanHeadingText(rawText);
1184
- const id = headingId(rawText);
1185
- if (!text || id === "empty-heading") continue;
1186
- if (level < minDepth || level > maxDepth) continue;
1187
- headings.push({ id, level, text });
1188
- }
1189
- return headings;
1190
- }
1191
- function urlIdToText(urlId) {
1192
- try {
1193
- if (typeof urlId !== "string") return "";
1194
- return urlId.replace(/^id-/, "").replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
1195
- } catch {
1196
- return "";
1197
- }
1198
- }
1
+ // src/index.ts
2
+ import { tags } from "@publish.os/nextjs/cache/tags";
3
+ import { createNextConfig } from "@publish.os/nextjs/config/createNextConfig";
4
+ import { PageList } from "@publish.os/nextjs/kernel/components/blocks/page-list";
5
+ import {
6
+ createAtomFeedRoute,
7
+ createJsonFeedRoute,
8
+ createRssFeedRoute
9
+ } from "@publish.os/nextjs/kernel/routes/metadata/feed";
10
+ import { createLlmsTxtRoute } from "@publish.os/nextjs/kernel/routes/metadata/llms";
11
+ import {
12
+ createOgImageRoute,
13
+ createOgImageStaticParams
14
+ } from "@publish.os/nextjs/kernel/routes/metadata/og-image";
15
+ import { createRobotsTxtRoute } from "@publish.os/nextjs/kernel/routes/metadata/robots";
16
+ import { createSitemapXmlRoute } from "@publish.os/nextjs/kernel/routes/metadata/sitemap";
17
+ import {
18
+ listStaticParams,
19
+ resolveGroup,
20
+ resolveGroupLayout,
21
+ resolveLeaf
22
+ } from "@publish.os/nextjs/resolvers/manifest-resolver";
23
+ import { cn } from "@publish.os/nextjs/utils/cn";
24
+ import {
25
+ cleanHeadingText,
26
+ createHeadingIdGenerator,
27
+ extractMdxHeadings,
28
+ headingToHTMLId,
29
+ urlIdToText
30
+ } from "@publish.os/nextjs/utils/heading-ids";
1199
31
  export {
1200
32
  PageList,
1201
33
  cleanHeadingText,