@publish.os/nextjs 0.0.1-alpha.90 → 0.0.1-alpha.92
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/compiler-assets/nextjs/defaults/group/index.tsx +16 -11
- package/compiler-assets/nextjs/defaults/group/layout.tsx +6 -6
- package/compiler-assets/nextjs/defaults/group/page.tsx +36 -26
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +21 -11
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -0
- package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
- package/compiler-assets/nextjs/defaults/root/index.tsx +16 -11
- package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -3
- package/compiler-assets/nextjs/shims/agent-user-agents.ts +65 -0
- package/compiler-assets/nextjs/shims/document.tsx +46 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +5 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +8 -42
- package/compiler-assets/nextjs/shims/global-not-found.tsx +69 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +2 -0
- package/compiler-assets/nextjs/shims/metadata-icons.tsx +39 -0
- package/compiler-assets/nextjs/shims/not-found-content.tsx +53 -0
- package/compiler-assets/nextjs/shims/not-found-navigation.tsx +60 -0
- package/compiler-assets/nextjs/shims/proxy.ts +254 -86
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +2 -6
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +28 -16
- package/compiler-assets/nextjs/shims/site-mdx.tsx +6 -1
- package/dist/{build-operation-2JAYBSKF.js → build-operation-CJDUL4OW.js} +29 -23
- package/dist/{button-c3WGnxIj.d.ts → button-D6Xp2HBm.d.ts} +4 -4
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -0
- package/dist/chunk-3T4HVDSC.js +426 -0
- package/dist/{chunk-WKTEO6RS.js → chunk-4BC2L2KA.js} +46 -12
- package/dist/{chunk-WDY4IK6Z.js → chunk-5J3YUNRY.js} +3 -10
- package/dist/chunk-5KAD7W53.js +248 -0
- package/dist/{chunk-DWA3ZRGW.js → chunk-6C65KV7O.js} +2 -2
- package/dist/{chunk-GGKFQ3MA.js → chunk-6D2E6UMD.js} +144 -70
- package/dist/{chunk-7OGTPSKI.js → chunk-7NY22B5U.js} +8 -3
- package/dist/chunk-DX7PXFCM.js +2519 -0
- package/dist/{chunk-726GV2NF.js → chunk-DZ3VWEV5.js} +950 -632
- package/dist/chunk-EFO6AWXN.js +19 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/{chunk-H6XILMZX.js → chunk-NHSLTARU.js} +2588 -1493
- package/dist/{chunk-DLDFHU7Y.js → chunk-NNBJZPFM.js} +4 -2
- package/dist/{chunk-VO2I7MTM.js → chunk-SBMDONTV.js} +10 -7
- package/dist/{chunk-YLTOLYWM.js → chunk-WL75GQ5M.js} +6 -18
- package/dist/compiler.d.ts +15 -2
- package/dist/compiler.js +111 -23
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +563 -0
- package/dist/components/blocks/toc.d.ts +43 -0
- package/dist/components/blocks/toc.js +136 -0
- package/dist/components/ui/button.d.ts +4 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-44GJSMXD.js +16 -0
- package/dist/config/createNextConfig.js +19 -3
- package/dist/{dev-operation-TZDVJCN7.js → dev-operation-WNECBHZ5.js} +134 -84
- package/dist/{framework-selection-X4U6Y6QC.js → framework-selection-ZVO323PK.js} +3 -2
- package/dist/ide-support-TG74L4FF.js +16 -0
- package/dist/index.d.ts +151 -95
- package/dist/index.js +25 -0
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.js +100 -0
- package/dist/jsx-runtime.d.ts +7 -0
- package/dist/jsx-runtime.js +97 -0
- package/dist/kernel/components/blocks/AgentActions.d.ts +37 -8
- package/dist/kernel/components/blocks/AgentActions.js +384 -174
- package/dist/kernel/components/blocks/agent-actions.d.ts +4 -0
- package/dist/kernel/components/blocks/agent-actions.js +563 -0
- package/dist/kernel/components/blocks/animated-icon-swap.d.ts +2 -2
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.d.ts +2 -2
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.d.ts +2 -2
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +6 -5
- package/dist/kernel/components/blocks/nav-breadcrumb.js +21 -15
- package/dist/kernel/components/blocks/navbar.d.ts +5 -4
- package/dist/kernel/components/blocks/navbar.js +79 -59
- package/dist/kernel/components/blocks/navigation-progress.d.ts +2 -2
- package/dist/kernel/components/blocks/navigation-progress.js +2 -2
- package/dist/kernel/components/blocks/next-prev.d.ts +4 -4
- package/dist/kernel/components/blocks/next-prev.js +30 -7
- package/dist/kernel/components/blocks/page-list.d.ts +4 -4
- package/dist/kernel/components/blocks/page-list.js +32 -9
- package/dist/kernel/components/blocks/search.d.ts +9 -15
- package/dist/kernel/components/blocks/search.js +16 -17
- package/dist/kernel/components/blocks/sidebar-node.d.ts +3 -5
- package/dist/kernel/components/blocks/sidebar-node.js +13 -3
- package/dist/kernel/components/blocks/sidebar.d.ts +6 -7
- package/dist/kernel/components/blocks/sidebar.js +137 -28
- package/dist/kernel/components/blocks/theme-toggle.d.ts +3 -4
- package/dist/kernel/components/blocks/theme-toggle.js +5 -5
- package/dist/kernel/components/blocks/toc-client.d.ts +40 -0
- package/dist/kernel/components/blocks/toc-client.js +495 -0
- package/dist/kernel/components/blocks/toc.d.ts +20 -2
- package/dist/kernel/components/blocks/toc.js +121 -179
- package/dist/kernel/components/mdx/components/blockquote.d.ts +2 -2
- package/dist/kernel/components/mdx/components/blockquote.js +1 -1
- package/dist/kernel/components/mdx/components/callout.d.ts +3 -3
- package/dist/kernel/components/mdx/components/callout.js +1 -1
- package/dist/kernel/components/mdx/components/code-block.d.ts +2 -2
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.d.ts +2 -2
- package/dist/kernel/components/mdx/components/copy-code-button.js +5 -4
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +3 -3
- package/dist/kernel/components/mdx/components/figure-caption.js +3 -2
- package/dist/kernel/components/mdx/components/figure.d.ts +8 -4
- package/dist/kernel/components/mdx/components/figure.js +23 -13
- package/dist/kernel/components/mdx/components/footnotes.d.ts +2 -2
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.d.ts +2 -2
- package/dist/kernel/components/mdx/components/heading-copy-link.js +1 -1
- package/dist/kernel/components/mdx/components/heading.d.ts +2 -2
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.d.ts +4 -4
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.d.ts +3 -3
- package/dist/kernel/components/mdx/components/image-zoom.js +4 -3
- package/dist/kernel/components/mdx/components/image.d.ts +2 -2
- package/dist/kernel/components/mdx/components/image.js +22 -17
- package/dist/kernel/components/mdx/components/inline-code.d.ts +2 -2
- package/dist/kernel/components/mdx/components/inline-code.js +1 -1
- package/dist/kernel/components/mdx/components/kbd.d.ts +3 -3
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +6 -6
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.d.ts +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +1 -1
- package/dist/kernel/components/mdx/components/strikethrough.d.ts +2 -2
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.d.ts +7 -7
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.d.ts +3 -3
- package/dist/kernel/components/mdx/components/task-list.js +1 -1
- package/dist/kernel/components/mdx/components/video-player.d.ts +8 -4
- package/dist/kernel/components/mdx/components/video-player.js +6 -2
- package/dist/kernel/components/mdx/components/video.d.ts +5 -4
- package/dist/kernel/components/mdx/components/video.js +7 -5
- package/dist/kernel/components/mdx/error-boundary.d.ts +3 -4
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.d.ts +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +57 -16
- package/dist/kernel/components/mdx/mdx.js +232 -35
- package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
- package/dist/kernel/components/mdx/rehype-heading-ids.js +5 -3
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/next-image.d.ts +12 -0
- package/dist/kernel/components/next-image.js +61 -0
- package/dist/kernel/components/ui/accordion.d.ts +7 -7
- package/dist/kernel/components/ui/accordion.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -4
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +14 -14
- package/dist/kernel/components/ui/breadcrumb.js +4 -4
- package/dist/kernel/components/ui/button-group.d.ts +6 -6
- package/dist/kernel/components/ui/button-group.js +3 -3
- package/dist/kernel/components/ui/button.d.ts +59 -7
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.d.ts +7 -7
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.d.ts +10 -10
- package/dist/kernel/components/ui/dialog.js +1 -1
- package/dist/kernel/components/ui/drawer.d.ts +12 -12
- package/dist/kernel/components/ui/drawer.js +1 -1
- package/dist/kernel/components/ui/input.d.ts +2 -2
- package/dist/kernel/components/ui/input.js +1 -1
- package/dist/kernel/components/ui/kbd.d.ts +4 -4
- package/dist/kernel/components/ui/kbd.js +1 -1
- package/dist/kernel/components/ui/link.d.ts +11 -5
- package/dist/kernel/components/ui/link.js +2 -2
- package/dist/kernel/components/ui/menu.d.ts +22 -22
- package/dist/kernel/components/ui/menu.js +1 -1
- package/dist/kernel/components/ui/mod-key.d.ts +2 -3
- package/dist/kernel/components/ui/mod-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.d.ts +15 -15
- package/dist/kernel/components/ui/navigation-menu.js +1 -1
- package/dist/kernel/components/ui/popover.d.ts +11 -11
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.d.ts +7 -7
- package/dist/kernel/components/ui/progress.js +1 -1
- package/dist/kernel/components/ui/scroll-area.d.ts +9 -10
- package/dist/kernel/components/ui/scroll-area.js +1 -1
- package/dist/kernel/components/ui/select.d.ts +16 -16
- package/dist/kernel/components/ui/select.js +1 -1
- package/dist/kernel/components/ui/separator.d.ts +3 -3
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.d.ts +7 -7
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.d.ts +12 -12
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.d.ts +3 -3
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +4 -4
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.d.ts +11 -11
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.d.ts +9 -9
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +4 -17
- package/dist/kernel/defaults.registry.js +4 -19
- package/dist/kernel/routes/agent/markdown.d.ts +7 -0
- package/dist/kernel/routes/agent/markdown.js +229 -54
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +5 -7
- package/dist/kernel/routes/metadata/feed.d.ts +1 -2
- package/dist/kernel/routes/metadata/feed.js +119 -88
- package/dist/kernel/routes/metadata/llms.d.ts +3 -23
- package/dist/kernel/routes/metadata/llms.js +2 -103
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +5 -3
- package/dist/kernel/routes/metadata/robots.js +4 -25
- package/dist/kernel/routes/metadata/sitemap.d.ts +36 -3
- package/dist/kernel/routes/metadata/sitemap.js +277 -49
- package/dist/kernel/routes/not-found.d.ts +34 -0
- package/dist/kernel/routes/not-found.js +213 -0
- package/dist/kernel/routes/pages/group.d.ts +5 -5
- package/dist/kernel/routes/pages/group.js +11 -5
- package/dist/kernel/routes/pages/leaf.d.ts +38 -6
- package/dist/kernel/routes/pages/leaf.js +21 -12
- package/dist/kernel/routes/pages/root.d.ts +5 -5
- package/dist/kernel/routes/pages/root.js +21 -6
- package/dist/keyboard-shortcuts.d.ts +2 -2
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/manifest-types-CcVPH_jh.d.ts +83 -0
- package/dist/resolvers/manifest-resolver.d.ts +2 -2
- package/dist/resolvers/manifest-resolver.js +65 -35
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.d.ts +2 -9
- package/dist/search.js +9 -16
- package/dist/sidebar-types-CMrMM0Nj.d.ts +105 -0
- package/dist/theme-scope.d.ts +2 -2
- package/dist/theme-scope.js +1 -1
- package/dist/types-BbqmOzLC.d.ts +168 -0
- package/dist/types-TjH1ek0X.d.ts +22 -0
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +117 -91
- package/dist/utils/heading-ids.js +30 -11
- package/dist/utils/toc-selection.d.ts +7 -0
- package/dist/utils/toc-selection.js +14 -0
- package/dist/validate-local-source-EN2GW4FR.js +16 -0
- package/dist/validate-publish-os-source-OEWQDB7B.js +14 -0
- package/init/seed/minimal/publish.os/assets/blog/hello-world.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.dark.svg +13 -0
- package/init/seed/minimal/publish.os/assets/favicon.svg +13 -0
- package/init/seed/minimal/publish.os/blog/content/hello-world.mdx +48 -0
- package/init/seed/minimal/publish.os/blog/content/series-a.mdx +11 -0
- package/init/seed/minimal/publish.os/blog/index.tsx +85 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +91 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
- package/init/seed/minimal/publish.os/components/blog/frontmatter.ts +41 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +2 -3
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +5 -6
- package/init/seed/minimal/publish.os/publish.os.config.json +17 -2
- package/init/seed/minimal/publish.os/theme.css +3 -3
- package/init/seed/minimal/seed.json +12 -4
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +1 -1
- package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
- package/package.json +48 -23
- package/release/app/phosphor/package.json +4 -4
- package/release/app/phosphor/pnpm-lock.yaml.template +123 -184
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +153 -183
- package/release/release.json +6 -6
- package/dist/button-CtzUJB8u.d.ts +0 -11
- package/dist/chunk-535TM4A5.js +0 -1455
- package/dist/chunk-B2V22WRT.js +0 -297
- package/dist/chunk-NECL5IBJ.js +0 -318
- package/dist/chunk-SVYGXXYR.js +0 -36
- package/dist/chunk-UF6ATARM.js +0 -1100
- package/dist/compose-NN23UJGC.js +0 -13
- package/dist/ide-support-ZNW7ODFY.js +0 -15
- package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
- package/dist/kernel/components/blocks/design-system-preview.js +0 -667
- package/dist/kernel/components/blocks/link-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/link-playground.js +0 -744
- package/dist/kernel/components/blocks/navigation-progress-playground.d.ts +0 -5
- package/dist/kernel/components/blocks/navigation-progress-playground.js +0 -629
- package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
- package/dist/kernel/components/ui/theme-toggle.js +0 -53
- package/dist/sidebar-types-DKpR27II.d.ts +0 -25
- package/dist/types-BzkZty3r.d.ts +0 -147
- package/dist/types-CJWRG05y.d.ts +0 -76
- package/dist/types-CUtrppxt.d.ts +0 -69
- package/dist/validate-local-source-XRL2Y7XE.js +0 -14
- package/dist/validate-publish-os-source-DAPZ4QGE.js +0 -12
- package/init/seed/minimal/publish.os/assets/favicon/favicon.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/favicon/favicon.png +0 -0
|
@@ -34,84 +34,244 @@ function createCachedTextResponse(options) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// src/route-not-found.ts
|
|
38
|
+
var MAX_PATH_LENGTH = 2048, UNSAFE_PATH_CHARACTERS = /[\p{Cc}\p{Cs}\u200b-\u200f\u2028-\u202f\u2060-\u206f\ufeff]/u, INTERNAL_PATHS = ["/__publishos", "/_next", "/_not-found", "/publishos"], DEFAULT_MARKDOWN = serializeNotFoundMarkdown({
|
|
39
|
+
recommendations: [],
|
|
40
|
+
indexes: []
|
|
41
|
+
});
|
|
42
|
+
function normalizePublicPath(pathname) {
|
|
43
|
+
let path = pathname.split(/[?#]/u, 1)[0];
|
|
44
|
+
if (!path?.startsWith("/") || path.startsWith("//") || path.length > MAX_PATH_LENGTH || UNSAFE_PATH_CHARACTERS.test(path))
|
|
45
|
+
return;
|
|
46
|
+
let segments = [];
|
|
47
|
+
for (let segment of path.split("/")) {
|
|
48
|
+
if (!segment) continue;
|
|
49
|
+
let decoded;
|
|
50
|
+
try {
|
|
51
|
+
decoded = decodeURIComponent(segment);
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (decoded === "." || decoded === ".." || /[/\\]/u.test(decoded) || /%[\da-f]{2}/iu.test(decoded) || UNSAFE_PATH_CHARACTERS.test(decoded))
|
|
56
|
+
return;
|
|
57
|
+
segments.push(decoded.normalize("NFC"));
|
|
58
|
+
}
|
|
59
|
+
return `/${segments.join("/")}`;
|
|
60
|
+
}
|
|
61
|
+
function containsPath({ parent, path }) {
|
|
62
|
+
return parent === "/" || path === parent || path.startsWith(`${parent}/`);
|
|
63
|
+
}
|
|
64
|
+
function missingPagePath(pathname) {
|
|
65
|
+
let normalized = normalizePublicPath(pathname);
|
|
66
|
+
if (!normalized) return;
|
|
67
|
+
let path = normalized.endsWith(".md") ? normalized.slice(0, -3) || "/" : normalized;
|
|
68
|
+
return INTERNAL_PATHS.some((parent) => containsPath({ parent, path })) ? void 0 : path;
|
|
69
|
+
}
|
|
70
|
+
function resolveNotFoundScope({
|
|
71
|
+
scopes,
|
|
72
|
+
pathname
|
|
73
|
+
}) {
|
|
74
|
+
let path = missingPagePath(pathname);
|
|
75
|
+
if (!path) return;
|
|
76
|
+
let matched, matchedLength = -1;
|
|
77
|
+
for (let scope of scopes) {
|
|
78
|
+
let scopePath = normalizePublicPath(scope.path);
|
|
79
|
+
!scopePath || !containsPath({ parent: scopePath, path }) || (scopePath.length > matchedLength || scopePath.length === matchedLength && scope.group && !matched?.group) && (matched = scope, matchedLength = scopePath.length);
|
|
80
|
+
}
|
|
81
|
+
return matched;
|
|
82
|
+
}
|
|
83
|
+
function trustedHostname(origin) {
|
|
84
|
+
if (origin)
|
|
85
|
+
try {
|
|
86
|
+
let url = new URL(origin);
|
|
87
|
+
return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : url.host.replace(/`/gu, "%60");
|
|
88
|
+
} catch {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function requestExplanation({
|
|
93
|
+
pathname,
|
|
94
|
+
origin
|
|
95
|
+
}) {
|
|
96
|
+
let path = pathname.split("/").map(encodeURIComponent).join("/"), hostname = trustedHostname(origin);
|
|
97
|
+
return `No page exists at \`${path}\`${hostname ? ` on ${hostname}` : ""}.`;
|
|
98
|
+
}
|
|
99
|
+
function indexKind(link) {
|
|
100
|
+
if (link.kind) return link.kind;
|
|
101
|
+
switch (link.title) {
|
|
102
|
+
case "Sitemap":
|
|
103
|
+
return "sitemap";
|
|
104
|
+
case "Markdown sitemap":
|
|
105
|
+
return "sitemap-md";
|
|
106
|
+
case "llms.txt":
|
|
107
|
+
case "LLMS index":
|
|
108
|
+
return "llms";
|
|
109
|
+
case "llms-full.txt":
|
|
110
|
+
return "llms-full";
|
|
111
|
+
default:
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function publicRecoveryHref(href) {
|
|
116
|
+
if (href.includes("\\") || UNSAFE_PATH_CHARACTERS.test(href))
|
|
117
|
+
return;
|
|
118
|
+
let relative = href.startsWith("/") && !href.startsWith("//");
|
|
119
|
+
try {
|
|
120
|
+
let url = new URL(
|
|
121
|
+
href,
|
|
122
|
+
relative ? "https://publishos.invalid" : void 0
|
|
123
|
+
);
|
|
124
|
+
return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : relative ? `${url.pathname}${url.search}${url.hash}` : url.href;
|
|
125
|
+
} catch {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function markdownText(value) {
|
|
130
|
+
return value.replace(/\s+/gu, " ").replace(/[\p{Cc}\p{Cs}]/gu, "").trim().replace(/[\\`*_[\]{}<>|~]/gu, "\\$&");
|
|
131
|
+
}
|
|
132
|
+
function markdownLink(link) {
|
|
133
|
+
let title = markdownText(link.title), href = publicRecoveryHref(link.href)?.replace(
|
|
134
|
+
/[()`<>]/gu,
|
|
135
|
+
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
|
|
136
|
+
);
|
|
137
|
+
if (!title || !href) return;
|
|
138
|
+
let description = link.description ? markdownText(link.description) : void 0;
|
|
139
|
+
return `- [${title}](${href})${description ? `: ${description}` : ""}`;
|
|
140
|
+
}
|
|
141
|
+
function serializeNotFoundMarkdown({
|
|
142
|
+
recommendations,
|
|
143
|
+
indexes
|
|
144
|
+
}) {
|
|
145
|
+
let sections = [
|
|
146
|
+
{ title: "Recommendations", links: recommendations },
|
|
147
|
+
{ title: "For crawlers and agents", links: indexes }
|
|
148
|
+
], lines = [
|
|
149
|
+
"# 404 \u2014 Not Found",
|
|
150
|
+
"",
|
|
151
|
+
"This page does not exist. Please check the URL and try again.",
|
|
152
|
+
""
|
|
153
|
+
];
|
|
154
|
+
for (let section of sections) {
|
|
155
|
+
let links = section.links.map(markdownLink).filter((link) => link !== void 0);
|
|
156
|
+
links.length && lines.push(`## ${section.title}`, "", ...links, "");
|
|
157
|
+
}
|
|
158
|
+
return lines.join(`
|
|
159
|
+
`);
|
|
160
|
+
}
|
|
161
|
+
function discoveryHeaders(scope) {
|
|
162
|
+
let headers = new Headers(), links = [];
|
|
163
|
+
for (let link of scope?.indexes ?? []) {
|
|
164
|
+
let kind = indexKind(link), href = /[\s<>"\\]/u.test(link.href) ? void 0 : publicRecoveryHref(link.href);
|
|
165
|
+
if (!(!kind || !href))
|
|
166
|
+
switch (kind) {
|
|
167
|
+
case "llms":
|
|
168
|
+
if (scope?.describedBy !== void 0) break;
|
|
169
|
+
links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href);
|
|
170
|
+
break;
|
|
171
|
+
case "llms-full":
|
|
172
|
+
links.push(
|
|
173
|
+
`<${href}>; rel="related"; type="text/plain"; title="Full content"`
|
|
174
|
+
);
|
|
175
|
+
break;
|
|
176
|
+
case "sitemap":
|
|
177
|
+
case "sitemap-md":
|
|
178
|
+
links.push(
|
|
179
|
+
`<${href}>; rel="sitemap"; type="${kind === "sitemap-md" ? "text/markdown" : "application/xml"}"`
|
|
180
|
+
), headers.set("x-publishos-sitemap", href);
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (scope?.describedBy !== void 0) {
|
|
185
|
+
let href = /[\s<>"\\]/u.test(scope.describedBy) ? void 0 : publicRecoveryHref(scope.describedBy);
|
|
186
|
+
href && (links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href));
|
|
187
|
+
}
|
|
188
|
+
return links.length && headers.set("link", links.join(", ")), headers;
|
|
189
|
+
}
|
|
190
|
+
function createNotFoundTextResponse({
|
|
191
|
+
scope,
|
|
192
|
+
pathname,
|
|
193
|
+
method,
|
|
194
|
+
contentType = "text/markdown; charset=utf-8",
|
|
195
|
+
vary = !1
|
|
196
|
+
}) {
|
|
197
|
+
let path = pathname === void 0 ? void 0 : missingPagePath(pathname), resolvedScope = scope && (pathname === void 0 || resolveNotFoundScope({ scopes: [scope], pathname })) ? scope : void 0, body = resolvedScope?.markdown ?? DEFAULT_MARKDOWN;
|
|
198
|
+
if (resolvedScope && path) {
|
|
199
|
+
let explanation = requestExplanation({
|
|
200
|
+
pathname: path,
|
|
201
|
+
origin: scope?.origin
|
|
202
|
+
}), headingEnd = body.indexOf(`
|
|
203
|
+
|
|
204
|
+
`);
|
|
205
|
+
body = headingEnd === -1 ? `${body}
|
|
206
|
+
|
|
207
|
+
${explanation}
|
|
208
|
+
` : `${body.slice(0, headingEnd)}
|
|
209
|
+
|
|
210
|
+
${explanation}
|
|
211
|
+
|
|
212
|
+
${body.slice(headingEnd + 2)}`;
|
|
213
|
+
}
|
|
214
|
+
let headers = discoveryHeaders(resolvedScope);
|
|
215
|
+
return vary && headers.set("vary", "Accept, User-Agent"), createCachedTextResponse({
|
|
216
|
+
body,
|
|
217
|
+
cachePolicy: "short",
|
|
218
|
+
contentType,
|
|
219
|
+
headers,
|
|
220
|
+
method,
|
|
221
|
+
noindex: !0,
|
|
222
|
+
status: 404
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
37
226
|
// src/route-agent-markdown.ts
|
|
38
|
-
var DEFAULT_DISCOVERY_LINKS = {
|
|
39
|
-
home: "/",
|
|
40
|
-
llms: "/llms.txt",
|
|
41
|
-
sitemap: "/sitemap.md"
|
|
42
|
-
};
|
|
43
227
|
function debugMarkdownResponse(details) {
|
|
44
228
|
log.debug("[agent-route]", "md-response", details);
|
|
45
229
|
}
|
|
46
230
|
function normalizeArtifactPath(parts) {
|
|
47
|
-
return parts?.length ? parts.some((part) => part === ".." || part.includes("\0")) ? null : `/${parts.join("/")}`.replace(/\/+/g, "/") : "/index.md";
|
|
231
|
+
return parts?.length ? parts.some((part) => part === ".." || part.includes("\0")) ? null : `/${parts.join("/")}`.replace(/\/+/g, "/").normalize("NFC") : "/index.md";
|
|
48
232
|
}
|
|
49
233
|
function findArtifactKey(artifacts, artifactPath) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (artifacts[suffixedPath]) return suffixedPath;
|
|
234
|
+
let suffixedPath = `${artifactPath}.md`;
|
|
235
|
+
return artifacts[suffixedPath] ? suffixedPath : artifacts[artifactPath] ? artifactPath : void 0;
|
|
53
236
|
}
|
|
54
237
|
function findArtifact(artifacts, artifactPath) {
|
|
55
|
-
return artifacts[artifactPath] ?? artifacts[
|
|
238
|
+
return artifacts[artifactPath] ?? artifacts[`${artifactPath}.md`];
|
|
56
239
|
}
|
|
57
240
|
function markdownHeaders(artifact) {
|
|
241
|
+
let robots = [
|
|
242
|
+
artifact.robots?.index === void 0 ? void 0 : artifact.robots.index ? "index" : "noindex",
|
|
243
|
+
artifact.robots?.follow === void 0 ? void 0 : artifact.robots.follow ? "follow" : "nofollow"
|
|
244
|
+
].filter(Boolean).join(", ");
|
|
58
245
|
return {
|
|
59
246
|
headers: {
|
|
60
|
-
link: `<${artifact.markdownPath}>; rel="alternate"; type="text/markdown", </llms.txt>; rel="llms-txt"; type="text/plain"
|
|
247
|
+
link: `<${new URL(artifact.markdownPath, "https://publish.invalid").pathname}>; rel="alternate"; type="text/markdown", </llms.txt>; rel="llms-txt"; type="text/plain"`,
|
|
248
|
+
...robots ? { "x-robots-tag": robots } : {}
|
|
61
249
|
},
|
|
62
250
|
contentType: "text/markdown; charset=utf-8"
|
|
63
251
|
};
|
|
64
252
|
}
|
|
65
|
-
function
|
|
66
|
-
return [
|
|
67
|
-
"# Not found",
|
|
68
|
-
"",
|
|
69
|
-
...[
|
|
70
|
-
discoveryLinks.home ? `> Home: ${discoveryLinks.home}` : void 0,
|
|
71
|
-
discoveryLinks.sitemap ? `> Sitemap: ${discoveryLinks.sitemap}` : void 0,
|
|
72
|
-
discoveryLinks.llms ? `> LLMS index: ${discoveryLinks.llms}` : void 0
|
|
73
|
-
].filter((line) => !!line),
|
|
74
|
-
"",
|
|
75
|
-
"The requested Markdown page was not found.",
|
|
76
|
-
""
|
|
77
|
-
].join(`
|
|
78
|
-
`);
|
|
79
|
-
}
|
|
80
|
-
function notFoundResponse(method, discoveryLinks, artifactPath, reason) {
|
|
253
|
+
function notFoundResponse(method, scopes, artifactPath, reason) {
|
|
81
254
|
return debugMarkdownResponse({
|
|
82
255
|
artifactPath,
|
|
83
256
|
method,
|
|
84
257
|
reason,
|
|
85
258
|
status: 404
|
|
86
|
-
}),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
method,
|
|
91
|
-
noindex: !0,
|
|
92
|
-
status: 404
|
|
259
|
+
}), createNotFoundTextResponse({
|
|
260
|
+
scope: artifactPath ? resolveNotFoundScope({ scopes, pathname: artifactPath }) : void 0,
|
|
261
|
+
pathname: artifactPath,
|
|
262
|
+
method
|
|
93
263
|
});
|
|
94
264
|
}
|
|
95
|
-
async function markdownResponse(artifacts,
|
|
265
|
+
async function markdownResponse(artifacts, scopes, method, context) {
|
|
96
266
|
let params = await Promise.resolve(context.params), artifactPath = normalizeArtifactPath(params?.path);
|
|
97
267
|
if (!artifactPath)
|
|
98
|
-
return notFoundResponse(method,
|
|
268
|
+
return notFoundResponse(method, scopes, void 0, "invalid-path");
|
|
99
269
|
let artifactKey = findArtifactKey(artifacts.index, artifactPath);
|
|
100
270
|
if (!artifactKey)
|
|
101
|
-
return notFoundResponse(
|
|
102
|
-
method,
|
|
103
|
-
discoveryLinks,
|
|
104
|
-
artifactPath,
|
|
105
|
-
"missing-index"
|
|
106
|
-
);
|
|
271
|
+
return notFoundResponse(method, scopes, artifactPath, "missing-index");
|
|
107
272
|
let artifact = await artifacts.loadArtifact(artifactKey);
|
|
108
273
|
if (!artifact)
|
|
109
|
-
return notFoundResponse(
|
|
110
|
-
method,
|
|
111
|
-
discoveryLinks,
|
|
112
|
-
artifactPath,
|
|
113
|
-
"missing-shard"
|
|
114
|
-
);
|
|
274
|
+
return notFoundResponse(method, scopes, artifactPath, "missing-shard");
|
|
115
275
|
let { contentType, headers } = markdownHeaders(artifact);
|
|
116
276
|
return debugMarkdownResponse({
|
|
117
277
|
artifactPath: artifact.markdownPath,
|
|
@@ -127,13 +287,28 @@ async function markdownResponse(artifacts, discoveryLinks, method, context) {
|
|
|
127
287
|
});
|
|
128
288
|
}
|
|
129
289
|
function createMarkdownRouteHandlers(artifacts, options = {}) {
|
|
130
|
-
let discoveryLinks = {
|
|
131
|
-
...
|
|
132
|
-
|
|
133
|
-
|
|
290
|
+
let links = options.discoveryLinks, recommendations = links?.home ? [{ title: "Go home", href: links.home }] : [], indexes = [
|
|
291
|
+
...links?.sitemap ? [
|
|
292
|
+
{
|
|
293
|
+
title: "Markdown sitemap",
|
|
294
|
+
href: links.sitemap,
|
|
295
|
+
kind: "sitemap-md"
|
|
296
|
+
}
|
|
297
|
+
] : [],
|
|
298
|
+
...links?.llms ? [{ title: "llms.txt", href: links.llms, kind: "llms" }] : []
|
|
299
|
+
], scopes = options.notFoundScopes ?? (links ? [
|
|
300
|
+
{
|
|
301
|
+
id: "root",
|
|
302
|
+
path: "/",
|
|
303
|
+
htmlPath: "",
|
|
304
|
+
recommendations,
|
|
305
|
+
indexes,
|
|
306
|
+
markdown: serializeNotFoundMarkdown({ recommendations, indexes })
|
|
307
|
+
}
|
|
308
|
+
] : []);
|
|
134
309
|
return {
|
|
135
|
-
GET: (_request, context) => markdownResponse(artifacts,
|
|
136
|
-
HEAD: (_request, context) => markdownResponse(artifacts,
|
|
310
|
+
GET: (_request, context) => markdownResponse(artifacts, scopes, "GET", context),
|
|
311
|
+
HEAD: (_request, context) => markdownResponse(artifacts, scopes, "HEAD", context),
|
|
137
312
|
generateStaticParams: () => Object.keys(artifacts.index).map((artifactPath) => ({
|
|
138
313
|
path: artifactPath.replace(/^\//, "").replace(/\.md$/, "").split("/")
|
|
139
314
|
}))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { M as ManifestLike, L as LayoutProps } from '../../../types-
|
|
3
|
+
import { M as ManifestLike, L as LayoutProps } from '../../../types-BbqmOzLC.js';
|
|
4
4
|
|
|
5
5
|
type LayoutComponent = (props: LayoutProps) => ReactElement | Promise<ReactElement>;
|
|
6
6
|
type GroupLayoutConfig = {
|
|
@@ -21,8 +21,8 @@ var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
// src/route-layout-group.tsx
|
|
24
|
-
import { jsx } from "
|
|
25
|
-
var manifests = /* @__PURE__ */ new Map()
|
|
24
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
25
|
+
var manifests = /* @__PURE__ */ new Map();
|
|
26
26
|
async function CachedGroupLayoutData({
|
|
27
27
|
routeGroup,
|
|
28
28
|
layoutGroup
|
|
@@ -39,12 +39,10 @@ function createGroupLayout({
|
|
|
39
39
|
manifest,
|
|
40
40
|
layouts
|
|
41
41
|
}) {
|
|
42
|
-
return manifests.set(group, manifest),
|
|
43
|
-
log.debug("[render]", `${group}/layout`);
|
|
44
|
-
let chain = layoutChains.get(group);
|
|
45
|
-
chain?.length || notFound();
|
|
42
|
+
return manifests.set(group, manifest), async function({ children }) {
|
|
43
|
+
log.debug("[render]", `${group}/layout`), layouts.length || notFound();
|
|
46
44
|
let resolvedLayouts = await Promise.all(
|
|
47
|
-
|
|
45
|
+
layouts.map(async (item) => ({
|
|
48
46
|
item,
|
|
49
47
|
props: await CachedGroupLayoutData({
|
|
50
48
|
layoutGroup: item.group,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as ManifestLike } from '../../../types-BbqmOzLC.js';
|
|
2
2
|
|
|
3
3
|
type FeedScope = "site" | "group" | "self";
|
|
4
4
|
type FeedRouteOptions = {
|
|
5
5
|
scope?: FeedScope;
|
|
6
6
|
group?: string;
|
|
7
7
|
limit?: number;
|
|
8
|
-
status?: PageStatus[];
|
|
9
8
|
};
|
|
10
9
|
type PrecomputedFeedOutput = {
|
|
11
10
|
body: string;
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
import { tags } from "@publish.os/nextjs/cache/tags";
|
|
3
3
|
import { cacheLife, cacheTag } from "next/cache";
|
|
4
4
|
|
|
5
|
+
// src/lib/runtime/metadata/authored-date.ts
|
|
6
|
+
function authoredDate(value) {
|
|
7
|
+
if (typeof value != "string" || !/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$/.test(
|
|
8
|
+
value
|
|
9
|
+
))
|
|
10
|
+
return;
|
|
11
|
+
let day = value.slice(0, 10), midnight = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
12
|
+
if (!(!Number.isFinite(midnight.getTime()) || midnight.toISOString().slice(0, 10) !== day))
|
|
13
|
+
return Number.isFinite(Date.parse(value)) ? value : void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
17
|
function canonicalUrl(manifest, path, group) {
|
|
7
18
|
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
|
-
if (!origin)
|
|
19
|
+
if (!origin)
|
|
20
|
+
return /^[a-z][a-z\d+.-]*:/i.test(path) ? path : new URL(path, "https://publish.invalid").pathname;
|
|
9
21
|
try {
|
|
10
22
|
return new URL(path, `${origin}/`).toString();
|
|
11
23
|
} catch {
|
|
@@ -13,6 +25,84 @@ function canonicalUrl(manifest, path, group) {
|
|
|
13
25
|
}
|
|
14
26
|
}
|
|
15
27
|
|
|
28
|
+
// src/lib/runtime/metadata/feed-serialization.ts
|
|
29
|
+
var siteBuildTime = process.env.PUBLISHOS_SITE_BUILD_TIME ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
30
|
+
function xmlEscape(value) {
|
|
31
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
32
|
+
}
|
|
33
|
+
function serializeRssFeed(input) {
|
|
34
|
+
let description = input.description ?? input.title, items = input.pages.map((page) => {
|
|
35
|
+
let publishedAt = page.publishedAt, pubDate = publishedAt ? `
|
|
36
|
+
<pubDate>${xmlEscape(new Date(publishedAt).toUTCString())}</pubDate>` : "", itemDescription = page.description ? `
|
|
37
|
+
<description>${xmlEscape(page.description)}</description>` : "";
|
|
38
|
+
return ` <item>
|
|
39
|
+
<title>${xmlEscape(page.title)}</title>
|
|
40
|
+
<link>${xmlEscape(page.url)}</link>
|
|
41
|
+
<guid>${xmlEscape(page.url)}</guid>${pubDate}${itemDescription}
|
|
42
|
+
</item>`;
|
|
43
|
+
}).join(`
|
|
44
|
+
`);
|
|
45
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
46
|
+
<rss version="2.0">
|
|
47
|
+
<channel>
|
|
48
|
+
<title>${xmlEscape(input.title)}</title>
|
|
49
|
+
<link>${xmlEscape(input.homeUrl)}</link>
|
|
50
|
+
<description>${xmlEscape(description)}</description>
|
|
51
|
+
${items}
|
|
52
|
+
</channel>
|
|
53
|
+
</rss>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
function serializeAtomFeed(input) {
|
|
57
|
+
let buildTime = input.buildTime ?? siteBuildTime, effectiveDates = input.pages.map(
|
|
58
|
+
(page) => new Date(page.updatedAt ?? page.publishedAt ?? buildTime).toISOString()
|
|
59
|
+
), entries = input.pages.map((page, index) => {
|
|
60
|
+
let updated = effectiveDates[index] ?? buildTime, summary = page.description ? `
|
|
61
|
+
<summary>${xmlEscape(page.description)}</summary>` : "";
|
|
62
|
+
return ` <entry>
|
|
63
|
+
<title>${xmlEscape(page.title)}</title>
|
|
64
|
+
<id>${xmlEscape(page.url)}</id>
|
|
65
|
+
<link href="${xmlEscape(page.url)}" />
|
|
66
|
+
<updated>${xmlEscape(updated)}</updated>${summary}
|
|
67
|
+
</entry>`;
|
|
68
|
+
}).join(`
|
|
69
|
+
`), latest = effectiveDates.length ? new Date(
|
|
70
|
+
Math.max(...effectiveDates.map((date) => Date.parse(date)))
|
|
71
|
+
).toISOString() : buildTime;
|
|
72
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
73
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
74
|
+
<title>${xmlEscape(input.title)}</title>
|
|
75
|
+
<id>${xmlEscape(input.homeUrl)}</id>
|
|
76
|
+
<author><name>${xmlEscape(input.author ?? input.title)}</name></author>
|
|
77
|
+
<updated>${xmlEscape(latest)}</updated>
|
|
78
|
+
${entries}
|
|
79
|
+
</feed>
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
function serializeJsonFeed(input) {
|
|
83
|
+
return `${JSON.stringify(
|
|
84
|
+
{
|
|
85
|
+
version: "https://jsonfeed.org/version/1.1",
|
|
86
|
+
title: input.title,
|
|
87
|
+
description: input.description,
|
|
88
|
+
home_page_url: input.homeUrl,
|
|
89
|
+
items: input.pages.map((page) => ({
|
|
90
|
+
id: page.url,
|
|
91
|
+
url: page.url,
|
|
92
|
+
title: page.title,
|
|
93
|
+
summary: page.description,
|
|
94
|
+
content_text: page.body,
|
|
95
|
+
date_published: page.publishedAt ? new Date(page.publishedAt).toISOString() : void 0,
|
|
96
|
+
date_modified: page.updatedAt ? new Date(page.updatedAt).toISOString() : void 0,
|
|
97
|
+
tags: page.tags
|
|
98
|
+
}))
|
|
99
|
+
},
|
|
100
|
+
null,
|
|
101
|
+
2
|
|
102
|
+
)}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
|
|
16
106
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
107
|
var CACHE_CONTROL = "public, max-age=300, s-maxage=3600, stale-while-revalidate=3600, must-revalidate", CDN_CACHE_CONTROL = "public, max-age=3600, stale-while-revalidate=3600, must-revalidate", SHORT_CACHE_CONTROL = "public, max-age=60, s-maxage=600, stale-while-revalidate=300, must-revalidate", SHORT_CDN_CACHE_CONTROL = "public, max-age=300, stale-while-revalidate=3600";
|
|
18
108
|
function cacheControl(policy) {
|
|
@@ -34,119 +124,60 @@ function createCachedTextResponse(options) {
|
|
|
34
124
|
}
|
|
35
125
|
|
|
36
126
|
// src/route-metadata-feed.ts
|
|
37
|
-
function xmlEscape(value) {
|
|
38
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
39
|
-
}
|
|
40
127
|
function pageTimestamp(page) {
|
|
41
|
-
let value =
|
|
128
|
+
let value = authoredDate(page.frontmatter.publishedAt) ?? authoredDate(page.frontmatter.updatedAt);
|
|
42
129
|
return value ? Date.parse(value) : -1 / 0;
|
|
43
130
|
}
|
|
44
|
-
function validDate(value) {
|
|
45
|
-
return value && !Number.isNaN(Date.parse(value)) ? value : void 0;
|
|
46
|
-
}
|
|
47
131
|
function pageInScope(page, options) {
|
|
48
132
|
return options.scope === "site" || !options.group ? !0 : options.scope === "self" ? page.group === options.group : page.group === options.group || page.group.startsWith(`${options.group}/`);
|
|
49
133
|
}
|
|
50
134
|
function feedPages(manifest, options) {
|
|
51
|
-
let
|
|
135
|
+
let pages = manifest.pages.filter((page) => page.frontmatter.status === "published").filter((page) => pageInScope(page, options)).sort((a, b) => pageTimestamp(b) - pageTimestamp(a));
|
|
52
136
|
return options.limit ? pages.slice(0, options.limit) : pages;
|
|
53
137
|
}
|
|
138
|
+
function feedInput(manifest, options = {}) {
|
|
139
|
+
let serializedPages = feedPages(manifest, options).map((page) => ({
|
|
140
|
+
url: canonicalUrl(manifest, page.path, page.group),
|
|
141
|
+
title: page.frontmatter.title,
|
|
142
|
+
publishedAt: authoredDate(page.frontmatter.publishedAt),
|
|
143
|
+
updatedAt: authoredDate(page.frontmatter.updatedAt),
|
|
144
|
+
description: page.frontmatter.description,
|
|
145
|
+
body: page.body,
|
|
146
|
+
tags: Array.isArray(page.frontmatter.tags) ? page.frontmatter.tags.filter(
|
|
147
|
+
(tag) => typeof tag == "string"
|
|
148
|
+
) : []
|
|
149
|
+
})), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/";
|
|
150
|
+
return {
|
|
151
|
+
// Public route factories use the site name; generated group feeds use the group title.
|
|
152
|
+
title: manifest.site.name,
|
|
153
|
+
description: manifest.site.description,
|
|
154
|
+
homeUrl: canonicalUrl(manifest, homePath, group),
|
|
155
|
+
pages: serializedPages
|
|
156
|
+
};
|
|
157
|
+
}
|
|
54
158
|
async function rssXml(manifest, options = {}) {
|
|
55
159
|
"use cache";
|
|
56
|
-
cacheLife("page"), cacheTag(
|
|
160
|
+
return cacheLife("page"), cacheTag(
|
|
57
161
|
tags.site(),
|
|
58
162
|
tags.feed("rss", options.group ?? options.scope ?? "site"),
|
|
59
163
|
tags.manifest(manifest.contentHash)
|
|
60
|
-
);
|
|
61
|
-
let title = manifest.site.name, description = manifest.site.description ?? title, pages = feedPages(manifest, options), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/", homeUrl = canonicalUrl(manifest, homePath, group), items = pages.map((page) => {
|
|
62
|
-
let pageUrl = canonicalUrl(manifest, page.path, page.group), publishedAt = validDate(page.publishedAt), pubDate = publishedAt ? `
|
|
63
|
-
<pubDate>${xmlEscape(new Date(publishedAt).toUTCString())}</pubDate>` : "", description2 = page.description ? `
|
|
64
|
-
<description>${xmlEscape(page.description)}</description>` : "";
|
|
65
|
-
return ` <item>
|
|
66
|
-
<title>${xmlEscape(page.title)}</title>
|
|
67
|
-
<link>${xmlEscape(pageUrl)}</link>
|
|
68
|
-
<guid>${xmlEscape(pageUrl)}</guid>${pubDate}${description2}
|
|
69
|
-
</item>`;
|
|
70
|
-
}).join(`
|
|
71
|
-
`);
|
|
72
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
73
|
-
<rss version="2.0">
|
|
74
|
-
<channel>
|
|
75
|
-
<title>${xmlEscape(title)}</title>
|
|
76
|
-
<link>${xmlEscape(homeUrl)}</link>
|
|
77
|
-
<description>${xmlEscape(description)}</description>
|
|
78
|
-
${items}
|
|
79
|
-
</channel>
|
|
80
|
-
</rss>
|
|
81
|
-
`;
|
|
82
|
-
}
|
|
83
|
-
function pageDate(page) {
|
|
84
|
-
return validDate(page.publishedAt) ?? validDate(page.updatedAt);
|
|
85
|
-
}
|
|
86
|
-
function latestFeedDate(pages) {
|
|
87
|
-
let timestamp = Math.max(0, ...pages.map((page) => pageTimestamp(page)));
|
|
88
|
-
return new Date(timestamp).toISOString();
|
|
164
|
+
), serializeRssFeed(feedInput(manifest, options));
|
|
89
165
|
}
|
|
90
166
|
async function atomXml(manifest, options = {}) {
|
|
91
167
|
"use cache";
|
|
92
|
-
cacheLife("page"), cacheTag(
|
|
168
|
+
return cacheLife("page"), cacheTag(
|
|
93
169
|
tags.site(),
|
|
94
170
|
tags.feed("atom", options.group ?? options.scope ?? "site"),
|
|
95
171
|
tags.manifest(manifest.contentHash)
|
|
96
|
-
);
|
|
97
|
-
let title = manifest.site.name, pages = feedPages(manifest, options), group = options.group, homePath = group ? manifest.groups[group]?.path ?? "/" : "/", homeUrl = canonicalUrl(manifest, homePath, group), entries = pages.map((page) => {
|
|
98
|
-
let date = pageDate(page), updated = date ? new Date(date).toISOString() : latestFeedDate([]), pageUrl = canonicalUrl(manifest, page.path, page.group), summary = page.description ? `
|
|
99
|
-
<summary>${xmlEscape(page.description)}</summary>` : "";
|
|
100
|
-
return ` <entry>
|
|
101
|
-
<title>${xmlEscape(page.title)}</title>
|
|
102
|
-
<id>${xmlEscape(pageUrl)}</id>
|
|
103
|
-
<link href="${xmlEscape(pageUrl)}" />
|
|
104
|
-
<updated>${xmlEscape(updated)}</updated>${summary}
|
|
105
|
-
</entry>`;
|
|
106
|
-
}).join(`
|
|
107
|
-
`);
|
|
108
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
109
|
-
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
110
|
-
<title>${xmlEscape(title)}</title>
|
|
111
|
-
<id>${xmlEscape(homeUrl)}</id>
|
|
112
|
-
<updated>${xmlEscape(latestFeedDate(pages))}</updated>
|
|
113
|
-
${entries}
|
|
114
|
-
</feed>
|
|
115
|
-
`;
|
|
172
|
+
), serializeAtomFeed(feedInput(manifest, options));
|
|
116
173
|
}
|
|
117
174
|
async function jsonFeed(manifest, options = {}) {
|
|
118
175
|
"use cache";
|
|
119
|
-
cacheLife("page"), cacheTag(
|
|
176
|
+
return cacheLife("page"), cacheTag(
|
|
120
177
|
tags.site(),
|
|
121
178
|
tags.feed("json", options.group ?? options.scope ?? "site"),
|
|
122
179
|
tags.manifest(manifest.contentHash)
|
|
123
|
-
);
|
|
124
|
-
let pages = feedPages(manifest, options);
|
|
125
|
-
return `${JSON.stringify(
|
|
126
|
-
{
|
|
127
|
-
version: "https://jsonfeed.org/version/1.1",
|
|
128
|
-
title: manifest.site.name,
|
|
129
|
-
description: manifest.site.description,
|
|
130
|
-
home_page_url: canonicalUrl(
|
|
131
|
-
manifest,
|
|
132
|
-
options.group ? manifest.groups[options.group]?.path ?? "/" : "/",
|
|
133
|
-
options.group
|
|
134
|
-
),
|
|
135
|
-
items: pages.map((page) => ({
|
|
136
|
-
id: canonicalUrl(manifest, page.path, page.group),
|
|
137
|
-
url: canonicalUrl(manifest, page.path, page.group),
|
|
138
|
-
title: page.title,
|
|
139
|
-
summary: page.description,
|
|
140
|
-
content_text: page.body,
|
|
141
|
-
date_published: validDate(page.publishedAt),
|
|
142
|
-
date_modified: validDate(page.updatedAt),
|
|
143
|
-
tags: page.tags
|
|
144
|
-
}))
|
|
145
|
-
},
|
|
146
|
-
null,
|
|
147
|
-
2
|
|
148
|
-
)}
|
|
149
|
-
`;
|
|
180
|
+
), serializeJsonFeed(feedInput(manifest, options));
|
|
150
181
|
}
|
|
151
182
|
function createRssFeedRoute(manifest, options = {}) {
|
|
152
183
|
return async function() {
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { M as ManifestLike } from '../../../types-BzkZty3r.js';
|
|
3
|
-
|
|
4
|
-
type LlmsRouteOptions = {
|
|
5
|
-
scope?: "site" | "group" | "self";
|
|
6
|
-
group?: string;
|
|
7
|
-
limit?: number;
|
|
8
|
-
includeDescriptions?: boolean;
|
|
9
|
-
links?: Array<{
|
|
10
|
-
title: string;
|
|
11
|
-
path: string;
|
|
12
|
-
group?: string;
|
|
13
|
-
}>;
|
|
14
|
-
};
|
|
15
|
-
type LlmsFullRouteOptions = {
|
|
16
|
-
maxBytes?: number;
|
|
17
|
-
};
|
|
18
|
-
type PrecomputedLlmsTxtOutput = {
|
|
1
|
+
type LlmsTxtOutput = {
|
|
19
2
|
body: string;
|
|
20
3
|
};
|
|
21
|
-
declare function createLlmsTxtRoute(
|
|
22
|
-
declare function createPrecomputedLlmsTxtRoute(output: PrecomputedLlmsTxtOutput): () => Response;
|
|
23
|
-
declare function llmsFullTxtResponse(manifest: ManifestLike, artifacts: MarkdownRouteArtifacts, options?: LlmsFullRouteOptions): Promise<Response>;
|
|
24
|
-
declare function createLlmsFullTxtRoute(manifest: ManifestLike, artifacts: MarkdownRouteArtifacts, options?: LlmsFullRouteOptions): () => Promise<Response>;
|
|
4
|
+
declare function createLlmsTxtRoute(output: LlmsTxtOutput): () => Response;
|
|
25
5
|
|
|
26
|
-
export { type
|
|
6
|
+
export { type LlmsTxtOutput, createLlmsTxtRoute };
|