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