@publish.os/nextjs 0.0.1-alpha.81 → 0.0.1-alpha.91
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/app/globals.css +1 -0
- package/compiler-assets/nextjs/defaults/group/index.tsx +50 -0
- package/compiler-assets/nextjs/defaults/group/layout.tsx +8 -8
- package/compiler-assets/nextjs/defaults/group/page.tsx +44 -43
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +33 -13
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +10 -3
- package/compiler-assets/nextjs/defaults/root/css/animation.css +131 -0
- package/compiler-assets/nextjs/defaults/root/css/components/code-block.css +18 -0
- package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +4 -1
- package/compiler-assets/nextjs/defaults/root/css/components/menu.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/popover.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/select.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +1 -1
- package/compiler-assets/nextjs/defaults/root/css/shadow.css +6 -25
- package/compiler-assets/nextjs/defaults/root/css/typography.css +51 -68
- package/compiler-assets/nextjs/defaults/root/globals.css +25 -0
- package/compiler-assets/nextjs/defaults/root/{page.tsx → index.tsx} +6 -2
- package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -1
- package/compiler-assets/nextjs/defaults/root/theme.css +22 -22
- package/compiler-assets/nextjs/shims/document.tsx +38 -0
- package/compiler-assets/nextjs/shims/generated-group-page.tsx +19 -2
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +18 -2
- package/compiler-assets/nextjs/shims/global-layout.tsx +19 -85
- 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 +143 -65
- package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +76 -15
- package/compiler-assets/nextjs/shims/root-page.tsx +7 -1
- package/compiler-assets/nextjs/shims/site-fenced-code-block.tsx +30 -0
- package/compiler-assets/nextjs/shims/site-heading-level.tsx +14 -0
- package/compiler-assets/nextjs/shims/site-mdx-components.tsx +112 -0
- package/compiler-assets/nextjs/shims/site-mdx.tsx +17 -0
- package/compiler-assets/nextjs/shims/theme-defaults.css +41 -25
- package/dist/build-operation-5QMLXF7N.js +89 -0
- package/dist/{button-CFdx-ohV.d.ts → button-BdCScEKi.d.ts} +6 -6
- package/dist/capture-local-source-WGGDIUU2.js +258 -0
- package/dist/chunk-22RSSUNV.js +13 -0
- package/dist/chunk-4BC2L2KA.js +620 -0
- package/dist/chunk-5J3YUNRY.js +121 -0
- package/dist/chunk-5KAD7W53.js +248 -0
- package/dist/chunk-6C65KV7O.js +142 -0
- package/dist/chunk-6D2E6UMD.js +695 -0
- package/dist/chunk-7NY22B5U.js +161 -0
- package/dist/chunk-AI2UULNX.js +9 -0
- package/dist/chunk-EFO6AWXN.js +19 -0
- package/dist/chunk-F3AGNDF4.js +2377 -0
- package/dist/chunk-GBPLER5H.js +426 -0
- package/dist/chunk-IL4RJOKI.js +186 -0
- package/dist/chunk-NNBJZPFM.js +193 -0
- package/dist/chunk-ORIUWJBQ.js +58 -0
- package/dist/chunk-OXOFRXEI.js +7129 -0
- package/dist/chunk-UYGCOWRF.js +1709 -0
- package/dist/chunk-WL75GQ5M.js +80 -0
- package/dist/compiler.d.ts +54 -7
- package/dist/compiler.js +121 -13147
- package/dist/components/blocks/agent-actions.d.ts +81 -0
- package/dist/components/blocks/agent-actions.js +594 -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 +5 -0
- package/dist/components/ui/button.js +94 -0
- package/dist/compose-CVBJRAF6.js +16 -0
- package/dist/config/createNextConfig.js +27 -0
- package/dist/dev-operation-OSHHWRWK.js +1095 -0
- package/dist/framework-selection-ZVO323PK.js +11 -0
- package/dist/ide-support-CU6Z5PVR.js +16 -0
- package/dist/index.d.ts +55 -4
- 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 +35 -6
- package/dist/kernel/components/blocks/AgentActions.js +401 -150
- package/dist/kernel/components/blocks/agent-actions.d.ts +5 -0
- package/dist/kernel/components/blocks/agent-actions.js +594 -0
- package/dist/kernel/components/blocks/animated-icon-swap.js +1 -1
- package/dist/kernel/components/blocks/color-palette.js +4 -4
- package/dist/kernel/components/blocks/logo-block.js +3 -3
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +10 -2
- package/dist/kernel/components/blocks/nav-breadcrumb.js +22 -7
- package/dist/kernel/components/blocks/navbar.d.ts +2 -2
- package/dist/kernel/components/blocks/navbar.js +406 -65
- package/dist/kernel/components/blocks/navigation-progress.js +6 -3
- package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
- package/dist/kernel/components/blocks/next-prev.js +12 -24
- package/dist/kernel/components/blocks/page-list.d.ts +1 -1
- package/dist/kernel/components/blocks/page-list.js +7 -6
- package/dist/kernel/components/blocks/search.d.ts +83 -58
- package/dist/kernel/components/blocks/search.js +554 -428
- package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
- package/dist/kernel/components/blocks/sidebar-node.js +12 -10
- package/dist/kernel/components/blocks/sidebar.d.ts +3 -3
- package/dist/kernel/components/blocks/sidebar.js +24 -14
- package/dist/kernel/components/blocks/theme-toggle.d.ts +2 -2
- package/dist/kernel/components/blocks/theme-toggle.js +47 -1
- 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 +19 -1
- package/dist/kernel/components/blocks/toc.js +122 -180
- package/dist/kernel/components/mdx/components/blockquote.js +2 -2
- package/dist/kernel/components/mdx/components/callout.d.ts +5 -7
- package/dist/kernel/components/mdx/components/callout.js +67 -36
- package/dist/kernel/components/mdx/components/code-block.d.ts +5 -2
- package/dist/kernel/components/mdx/components/code-block.js +106 -5
- package/dist/kernel/components/mdx/components/copy-code-button.d.ts +8 -0
- package/dist/kernel/components/mdx/components/copy-code-button.js +61 -0
- package/dist/kernel/components/mdx/components/figure-caption.d.ts +1 -1
- package/dist/kernel/components/mdx/components/figure-caption.js +4 -3
- package/dist/kernel/components/mdx/components/figure.d.ts +6 -2
- package/dist/kernel/components/mdx/components/figure.js +24 -14
- package/dist/kernel/components/mdx/components/footnotes.js +1 -1
- package/dist/kernel/components/mdx/components/heading-copy-link.js +4 -4
- package/dist/kernel/components/mdx/components/heading.js +6 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +2 -2
- package/dist/kernel/components/mdx/components/image.d.ts +1 -1
- package/dist/kernel/components/mdx/components/image.js +94 -68
- package/dist/kernel/components/mdx/components/inline-code.js +2 -2
- package/dist/kernel/components/mdx/components/kbd.d.ts +2 -2
- package/dist/kernel/components/mdx/components/kbd.js +5 -4
- package/dist/kernel/components/mdx/components/link.d.ts +35 -4
- package/dist/kernel/components/mdx/components/link.js +3 -3
- package/dist/kernel/components/mdx/components/paragraph.js +2 -5
- package/dist/kernel/components/mdx/components/strikethrough.js +1 -1
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +2 -2
- package/dist/kernel/components/mdx/components/video-player.d.ts +6 -2
- package/dist/kernel/components/mdx/components/video-player.js +8 -4
- package/dist/kernel/components/mdx/components/video.d.ts +5 -3
- package/dist/kernel/components/mdx/components/video.js +8 -6
- package/dist/kernel/components/mdx/error-boundary.js +2 -2
- package/dist/kernel/components/mdx/error-fallback.js +1 -1
- package/dist/kernel/components/mdx/mdx.d.ts +28 -14
- package/dist/kernel/components/mdx/mdx.js +336 -63
- package/dist/kernel/components/mdx/rehype-heading-ids.d.ts +1 -0
- package/dist/kernel/components/mdx/rehype-heading-ids.js +6 -4
- 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.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +6 -23
- package/dist/kernel/components/ui/breadcrumb-trail.js +2 -2
- package/dist/kernel/components/ui/breadcrumb.d.ts +11 -3
- package/dist/kernel/components/ui/breadcrumb.js +10 -8
- package/dist/kernel/components/ui/button-group.js +8 -7
- package/dist/kernel/components/ui/button.d.ts +58 -6
- package/dist/kernel/components/ui/button.js +43 -39
- package/dist/kernel/components/ui/card.d.ts +2 -2
- package/dist/kernel/components/ui/card.js +1 -1
- package/dist/kernel/components/ui/dialog.js +1 -1
- package/dist/kernel/components/ui/drawer.d.ts +3 -1
- package/dist/kernel/components/ui/drawer.js +6 -2
- 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.js +10 -17
- package/dist/kernel/components/ui/link.d.ts +11 -3
- package/dist/kernel/components/ui/link.js +12 -11
- package/dist/kernel/components/ui/menu.js +6 -6
- package/dist/kernel/components/ui/mod-key.d.ts +10 -0
- package/dist/kernel/components/ui/mod-key.js +36 -0
- package/dist/kernel/components/ui/navigation-menu.js +3 -3
- package/dist/kernel/components/ui/popover.js +1 -1
- package/dist/kernel/components/ui/progress.js +2 -2
- package/dist/kernel/components/ui/scroll-area.js +5 -5
- package/dist/kernel/components/ui/select.js +8 -11
- package/dist/kernel/components/ui/separator.js +1 -1
- package/dist/kernel/components/ui/table.js +1 -1
- package/dist/kernel/components/ui/tabs.js +1 -1
- package/dist/kernel/components/ui/tag.js +1 -1
- package/dist/kernel/components/ui/text.d.ts +2 -2
- package/dist/kernel/components/ui/text.js +1 -1
- package/dist/kernel/components/ui/toast.js +1 -1
- package/dist/kernel/components/ui/tooltip.js +1 -1
- package/dist/kernel/defaults.registry.d.ts +11 -24
- package/dist/kernel/defaults.registry.js +11 -26
- package/dist/kernel/routes/agent/markdown.d.ts +3 -1
- package/dist/kernel/routes/agent/markdown.js +219 -48
- 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 -1
- package/dist/kernel/routes/metadata/feed.js +111 -81
- package/dist/kernel/routes/metadata/llms.d.ts +12 -3
- package/dist/kernel/routes/metadata/llms.js +156 -59
- package/dist/kernel/routes/metadata/og-image.js +1 -1
- package/dist/kernel/routes/metadata/robots.d.ts +1 -1
- package/dist/kernel/routes/metadata/robots.js +2 -2
- package/dist/kernel/routes/metadata/sitemap.d.ts +26 -4
- package/dist/kernel/routes/metadata/sitemap.js +206 -38
- 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 +2 -2
- package/dist/kernel/routes/pages/group.js +21 -13
- package/dist/kernel/routes/pages/leaf.d.ts +28 -1
- package/dist/kernel/routes/pages/leaf.js +25 -16
- package/dist/kernel/routes/pages/root.js +19 -13
- package/dist/keyboard-shortcuts.js +1 -1
- package/dist/resolvers/manifest-resolver.js +29 -6
- package/dist/search.d.ts +6 -7
- package/dist/search.js +52 -29
- package/dist/{sidebar-types-Bgchdfd6.d.ts → sidebar-types-DKpR27II.d.ts} +1 -1
- package/dist/theme-scope.js +1 -1
- package/dist/{types-DHBm7-j6.d.ts → types-CJWRG05y.d.ts} +20 -1
- package/dist/{types-B_b3C0U6.d.ts → types-CUtrppxt.d.ts} +8 -2
- package/dist/{types-CIwwieNw.d.ts → types-J2w_puPF.d.ts} +11 -10
- package/dist/types.d.ts +15 -6
- 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-SV44DBQT.js +16 -0
- package/dist/validate-publish-os-source-NZJF3TB2.js +14 -0
- package/init/seed/minimal/.gitignore +1 -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 +82 -0
- package/init/seed/minimal/publish.os/blog/layout.tsx +13 -0
- package/init/seed/minimal/publish.os/blog/page.tsx +76 -0
- package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +64 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +6 -11
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +6 -7
- package/init/seed/minimal/publish.os/docs/content/{theme.mdx → themes.mdx} +14 -12
- package/init/seed/minimal/publish.os/publish.os.config.json +7 -7
- package/init/seed/minimal/publish.os/theme.css +52 -24
- package/init/seed/minimal/publish.os/tsconfig.json +3 -0
- package/init/seed/minimal/seed.json +12 -2
- package/init/seed/scratch/publish.os/docs/content/get-started.mdx +6 -0
- package/init/seed/scratch/publish.os/publish.os.config.json +4 -0
- package/init/seed/scratch/seed.json +5 -0
- package/package.json +55 -44
- package/release/app/phosphor/package.json +5 -5
- package/release/app/phosphor/pnpm-lock.yaml.template +553 -377
- package/release/app/phosphor/pnpm-workspace.yaml +3 -0
- package/release/compiler/package.json +5 -3
- package/release/compiler/pnpm-lock.yaml.template +500 -303
- package/release/compiler/pnpm-workspace.yaml +3 -0
- package/release/release.json +8 -37
- package/compiler-assets/nextjs/defaults/group/leaf.tsx +0 -48
- package/dist/icons.d.ts +0 -1
- package/dist/icons.js +0 -2
- package/dist/kernel/components/blocks/design-system-preview.d.ts +0 -61
- package/dist/kernel/components/blocks/design-system-preview.js +0 -648
- 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/mdx/components/pre.d.ts +0 -6
- package/dist/kernel/components/mdx/components/pre.js +0 -18
- package/dist/kernel/components/ui/meta-key.d.ts +0 -17
- package/dist/kernel/components/ui/meta-key.js +0 -9
- package/dist/kernel/components/ui/theme-toggle.d.ts +0 -24
- package/dist/kernel/components/ui/theme-toggle.js +0 -58
- package/dist/kernel/framework-icons.d.ts +0 -1
- package/dist/kernel/framework-icons.js +0 -39
- package/dist/link-CYaCRDb6.d.ts +0 -35
- package/release/app/lucide/package.json +0 -30
- package/release/app/lucide/pnpm-lock.yaml.template +0 -2905
- package/release/app/lucide/pnpm-workspace.yaml +0 -11
- package/release/app/tabler/package.json +0 -30
- package/release/app/tabler/pnpm-lock.yaml.template +0 -2911
- package/release/app/tabler/pnpm-workspace.yaml +0 -11
|
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
|
|
|
3
3
|
import { cacheLife, cacheTag } from "next/cache";
|
|
4
4
|
|
|
5
5
|
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
|
-
function canonicalUrl(manifest, path) {
|
|
7
|
-
let origin = manifest.site.
|
|
6
|
+
function canonicalUrl(manifest, path, group) {
|
|
7
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
8
|
if (!origin) return path;
|
|
9
9
|
try {
|
|
10
10
|
return new URL(path, `${origin}/`).toString();
|
|
@@ -13,6 +13,122 @@ function canonicalUrl(manifest, path) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// src/lib/runtime/metadata/discovery-content.ts
|
|
17
|
+
function discoveryOrigin(manifest, group) {
|
|
18
|
+
return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
|
|
19
|
+
}
|
|
20
|
+
function pathWithin(path, basePath) {
|
|
21
|
+
return basePath === "/" || path === basePath || path.startsWith(`${basePath}/`);
|
|
22
|
+
}
|
|
23
|
+
function discoveryPages({
|
|
24
|
+
manifest,
|
|
25
|
+
group,
|
|
26
|
+
scope,
|
|
27
|
+
limit
|
|
28
|
+
}) {
|
|
29
|
+
let origin = discoveryOrigin(manifest, group), basePath = group ? manifest.groups[group]?.path ?? "/" : "/", pages = manifest.pages.filter((page) => page.status !== "published" || discoveryOrigin(manifest, page.group) !== origin ? !1 : !group || scope === "site" ? !0 : pathWithin(page.path, basePath) ? page.group === group || scope !== "self" && page.group.startsWith(`${group}/`) : !1);
|
|
30
|
+
return limit ? pages.slice(0, limit) : pages;
|
|
31
|
+
}
|
|
32
|
+
function groupDiscoveryPages({
|
|
33
|
+
manifest,
|
|
34
|
+
pages
|
|
35
|
+
}) {
|
|
36
|
+
let sections = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let page of pages) {
|
|
38
|
+
let group = manifest.groups[page.group], key = group ? page.group : "", section = sections.get(key);
|
|
39
|
+
section || (section = {
|
|
40
|
+
...group ? { group: page.group } : {},
|
|
41
|
+
title: group ? group.key === "__root" ? manifest.site.name : group.title : "Pages",
|
|
42
|
+
pages: []
|
|
43
|
+
}, sections.set(key, section)), section.pages.push(page);
|
|
44
|
+
}
|
|
45
|
+
return [...sections.values()].sort(
|
|
46
|
+
(a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
|
|
47
|
+
manifest.groups[b.group ?? ""]?.path ?? "/"
|
|
48
|
+
) || a.title.localeCompare(b.title)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/lib/runtime/metadata/llms-serialization.ts
|
|
53
|
+
function inlineText(value) {
|
|
54
|
+
return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
|
|
55
|
+
}
|
|
56
|
+
function markdownLink(link) {
|
|
57
|
+
let url = link.url.replace(
|
|
58
|
+
/[\s()<>]/g,
|
|
59
|
+
(value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
|
|
60
|
+
);
|
|
61
|
+
return `[${inlineText(link.title)}](${url})`;
|
|
62
|
+
}
|
|
63
|
+
function serializeLlmsIndex(input) {
|
|
64
|
+
let body = (input.sections ?? [
|
|
65
|
+
{ title: "Pages", pages: input.pages ?? [] }
|
|
66
|
+
]).map((section) => {
|
|
67
|
+
let lines = [
|
|
68
|
+
...(section.links ?? []).map((link) => `- ${markdownLink(link)}`),
|
|
69
|
+
...section.pages.map((page) => {
|
|
70
|
+
let description = input.includeDescriptions && page.description ? `: ${inlineText(page.description)}` : "", alternate = page.alternate ? ` (${markdownLink(page.alternate)})` : "";
|
|
71
|
+
return `- ${markdownLink(page)}${alternate}${description}`;
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
return `## ${inlineText(section.title)}
|
|
75
|
+
|
|
76
|
+
${lines.join(`
|
|
77
|
+
`)}`;
|
|
78
|
+
}).join(`
|
|
79
|
+
|
|
80
|
+
`), linkLines = (input.links ?? []).map(
|
|
81
|
+
(link) => `- ${markdownLink(link)}`
|
|
82
|
+
), linkSection = linkLines.length ? `
|
|
83
|
+
|
|
84
|
+
## Group LLM indexes
|
|
85
|
+
|
|
86
|
+
${linkLines.join(`
|
|
87
|
+
`)}` : "", otherGroupLines = (input.otherGroupLinks ?? []).map(
|
|
88
|
+
(link) => `- ${markdownLink(link)}`
|
|
89
|
+
), otherGroupSection = otherGroupLines.length ? `
|
|
90
|
+
|
|
91
|
+
## Other content groups
|
|
92
|
+
|
|
93
|
+
${otherGroupLines.join(`
|
|
94
|
+
`)}` : "";
|
|
95
|
+
return `# ${inlineText(input.title)}
|
|
96
|
+
|
|
97
|
+
> ${inlineText(input.summary)}
|
|
98
|
+
|
|
99
|
+
${body}${linkSection}${otherGroupSection}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
function serializeLlmsFull(input) {
|
|
103
|
+
let encoder = new TextEncoder(), byteLength = (value) => encoder.encode(value).byteLength, references = [
|
|
104
|
+
input.indexUrl ? `> LLMS index: ${input.indexUrl}` : void 0,
|
|
105
|
+
input.sitemapUrl ? `> Sitemap: ${input.sitemapUrl}` : void 0
|
|
106
|
+
].filter(Boolean).join(`
|
|
107
|
+
`), header = `# ${input.title} Full Content
|
|
108
|
+
|
|
109
|
+
${references ? `${references}
|
|
110
|
+
|
|
111
|
+
` : ""}`, sections = [], totalBytes = byteLength(header), included = 0, truncated = !1;
|
|
112
|
+
for (let artifact of [...input.artifacts].sort(
|
|
113
|
+
(a, b) => a.markdownPath.localeCompare(b.markdownPath)
|
|
114
|
+
)) {
|
|
115
|
+
let section = `---
|
|
116
|
+
|
|
117
|
+
${artifact.body.trim()}
|
|
118
|
+
|
|
119
|
+
`, sectionBytes = byteLength(section);
|
|
120
|
+
if (totalBytes + sectionBytes > input.maxBytes) {
|
|
121
|
+
truncated = !0;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
sections.push(section), totalBytes += sectionBytes, included += 1;
|
|
125
|
+
}
|
|
126
|
+
let footer = truncated ? `
|
|
127
|
+
> Truncated at ${included} of ${input.totalCount ?? input.artifacts.length} Markdown pages to stay under ${input.maxBytes} bytes.
|
|
128
|
+
` : "";
|
|
129
|
+
return `${header}${sections.join("")}${footer}`;
|
|
130
|
+
}
|
|
131
|
+
|
|
16
132
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
133
|
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
134
|
function cacheControl(policy) {
|
|
@@ -34,48 +150,45 @@ function createCachedTextResponse(options) {
|
|
|
34
150
|
}
|
|
35
151
|
|
|
36
152
|
// src/route-metadata-llms.ts
|
|
37
|
-
var DEFAULT_LLMS_FULL_MAX_BYTES = 1e6
|
|
38
|
-
function
|
|
39
|
-
return TEXT_ENCODER.encode(value).byteLength;
|
|
40
|
-
}
|
|
41
|
-
function pageInScope(page, options) {
|
|
42
|
-
return options.scope === "site" || !options.group ? !0 : options.scope === "self" ? page.group === options.group : page.group === options.group || page.group.startsWith(`${options.group}/`);
|
|
43
|
-
}
|
|
44
|
-
function llmsSummary(manifest) {
|
|
45
|
-
return manifest.site.description ? `> ${manifest.site.description}` : `> Agent-readable index for ${manifest.site.name}.`;
|
|
46
|
-
}
|
|
47
|
-
async function llmsTxt(manifest, options = {}) {
|
|
153
|
+
var DEFAULT_LLMS_FULL_MAX_BYTES = 1e6;
|
|
154
|
+
async function llmsTxt(manifest, options = {}, artifactManifest) {
|
|
48
155
|
"use cache";
|
|
49
156
|
cacheLife("page"), cacheTag(
|
|
50
157
|
tags.site(),
|
|
51
158
|
tags.llms(options.group ?? options.scope ?? "root"),
|
|
52
159
|
tags.manifest(manifest.contentHash)
|
|
53
160
|
);
|
|
54
|
-
let pages =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
161
|
+
let pages = discoveryPages({ manifest, ...options }), group = options.group ? manifest.groups[options.group] : void 0;
|
|
162
|
+
return serializeLlmsIndex({
|
|
163
|
+
title: group?.title ?? manifest.site.name,
|
|
164
|
+
summary: manifest.site.description ? manifest.site.description : `Agent-readable index for ${manifest.site.name}.`,
|
|
165
|
+
sections: groupDiscoveryPages({ manifest, pages }).map((section) => ({
|
|
166
|
+
title: section.title,
|
|
167
|
+
pages: section.pages.map((page) => ({
|
|
168
|
+
title: page.title,
|
|
169
|
+
url: canonicalUrl(
|
|
170
|
+
manifest,
|
|
171
|
+
artifactManifest?.byHtmlPath[page.path] ?? page.path,
|
|
172
|
+
page.group
|
|
173
|
+
),
|
|
174
|
+
description: page.description
|
|
175
|
+
}))
|
|
176
|
+
})),
|
|
177
|
+
includeDescriptions: options.includeDescriptions,
|
|
178
|
+
links: options.links?.map((link) => ({
|
|
179
|
+
title: link.title,
|
|
180
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
181
|
+
})),
|
|
182
|
+
otherGroupLinks: options.otherGroupLinks?.map((link) => ({
|
|
183
|
+
title: link.title,
|
|
184
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
185
|
+
}))
|
|
186
|
+
});
|
|
74
187
|
}
|
|
75
|
-
function createLlmsTxtRoute(manifest, options = {}) {
|
|
188
|
+
function createLlmsTxtRoute(manifest, options = {}, artifactManifest) {
|
|
76
189
|
return async function() {
|
|
77
190
|
return createCachedTextResponse({
|
|
78
|
-
body: await llmsTxt(manifest, options),
|
|
191
|
+
body: await llmsTxt(manifest, options, artifactManifest),
|
|
79
192
|
contentType: "text/plain; charset=utf-8"
|
|
80
193
|
});
|
|
81
194
|
};
|
|
@@ -89,30 +202,14 @@ function createPrecomputedLlmsTxtRoute(output) {
|
|
|
89
202
|
};
|
|
90
203
|
}
|
|
91
204
|
async function llmsFullTxt(manifest, artifacts, options = {}) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)) {
|
|
101
|
-
let section = `---
|
|
102
|
-
|
|
103
|
-
${artifact.body.trim()}
|
|
104
|
-
|
|
105
|
-
`, sectionBytes = byteLength(section);
|
|
106
|
-
if (totalBytes + sectionBytes > maxBytes) {
|
|
107
|
-
truncated = !0;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
sections.push(section), totalBytes += sectionBytes, included += 1;
|
|
111
|
-
}
|
|
112
|
-
let footer = truncated ? `
|
|
113
|
-
> Truncated at ${included} of ${Object.keys(artifacts).length} Markdown pages to stay under ${maxBytes} bytes.
|
|
114
|
-
` : "";
|
|
115
|
-
return `${header}${sections.join("")}${footer}`;
|
|
205
|
+
return serializeLlmsFull({
|
|
206
|
+
title: manifest.site.name,
|
|
207
|
+
indexUrl: options.indexPath === !1 ? void 0 : canonicalUrl(manifest, options.indexPath ?? "/llms.txt"),
|
|
208
|
+
sitemapUrl: options.sitemapPath === !1 ? void 0 : canonicalUrl(manifest, options.sitemapPath ?? "/sitemap.md"),
|
|
209
|
+
// Route factories serialize their supplied artifacts; generated output filters by origin.
|
|
210
|
+
artifacts: Object.values(artifacts),
|
|
211
|
+
maxBytes: options.maxBytes ?? DEFAULT_LLMS_FULL_MAX_BYTES
|
|
212
|
+
});
|
|
116
213
|
}
|
|
117
214
|
async function llmsFullTxtResponse(manifest, artifacts, options = {}) {
|
|
118
215
|
return createCachedTextResponse({
|
|
@@ -116,7 +116,7 @@ function getOgImageText(entry) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// src/route-metadata-og-image.tsx
|
|
119
|
-
import { jsx, jsxs } from "
|
|
119
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
120
120
|
var ERROR_HEADERS = {
|
|
121
121
|
"cache-control": "public, max-age=60, must-revalidate",
|
|
122
122
|
"cdn-cache-control": "public, max-age=300",
|
|
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
|
|
|
3
3
|
import { cacheLife, cacheTag } from "next/cache";
|
|
4
4
|
|
|
5
5
|
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
|
-
function canonicalUrl(manifest, path) {
|
|
7
|
-
let origin = manifest.site.
|
|
6
|
+
function canonicalUrl(manifest, path, group) {
|
|
7
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
8
|
if (!origin) return path;
|
|
9
9
|
try {
|
|
10
10
|
return new URL(path, `${origin}/`).toString();
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import { MarkdownRouteArtifactManifest } from '../agent/markdown.js';
|
|
2
|
-
import { M as ManifestLike } from '../../../types-
|
|
2
|
+
import { M as ManifestLike } from '../../../types-J2w_puPF.js';
|
|
3
|
+
import '../not-found.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type SitemapReference = {
|
|
6
|
+
path: string;
|
|
7
|
+
group?: string;
|
|
8
|
+
};
|
|
9
|
+
type SitemapRouteOptions = {
|
|
10
|
+
group?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
sitemaps?: SitemapReference[];
|
|
13
|
+
exclude?: SitemapReference[];
|
|
14
|
+
};
|
|
15
|
+
type SitemapMarkdownRouteOptions = {
|
|
16
|
+
group?: string;
|
|
17
|
+
scope?: "site" | "group" | "self";
|
|
18
|
+
links?: Array<SitemapReference & {
|
|
19
|
+
title: string;
|
|
20
|
+
}>;
|
|
21
|
+
otherGroupLinks?: Array<SitemapReference & {
|
|
22
|
+
title: string;
|
|
23
|
+
}>;
|
|
24
|
+
markdownAlternates?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare function createSitemapXmlRoute(manifest: ManifestLike, options?: SitemapRouteOptions): () => Promise<Response>;
|
|
27
|
+
declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest, options?: SitemapMarkdownRouteOptions): () => Promise<Response>;
|
|
6
28
|
|
|
7
|
-
export { createSitemapMarkdownRoute, createSitemapXmlRoute };
|
|
29
|
+
export { type SitemapMarkdownRouteOptions, type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
|
|
@@ -3,8 +3,8 @@ import { tags } from "@publish.os/nextjs/cache/tags";
|
|
|
3
3
|
import { cacheLife, cacheTag } from "next/cache";
|
|
4
4
|
|
|
5
5
|
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
|
-
function canonicalUrl(manifest, path) {
|
|
7
|
-
let origin = manifest.site.
|
|
6
|
+
function canonicalUrl(manifest, path, group) {
|
|
7
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
8
|
if (!origin) return path;
|
|
9
9
|
try {
|
|
10
10
|
return new URL(path, `${origin}/`).toString();
|
|
@@ -13,6 +13,93 @@ function canonicalUrl(manifest, path) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// src/lib/runtime/metadata/discovery-content.ts
|
|
17
|
+
function discoveryOrigin(manifest, group) {
|
|
18
|
+
return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
|
|
19
|
+
}
|
|
20
|
+
function pathWithin(path, basePath) {
|
|
21
|
+
return basePath === "/" || path === basePath || path.startsWith(`${basePath}/`);
|
|
22
|
+
}
|
|
23
|
+
function discoveryPages({
|
|
24
|
+
manifest,
|
|
25
|
+
group,
|
|
26
|
+
scope,
|
|
27
|
+
limit
|
|
28
|
+
}) {
|
|
29
|
+
let origin = discoveryOrigin(manifest, group), basePath = group ? manifest.groups[group]?.path ?? "/" : "/", pages = manifest.pages.filter((page) => page.status !== "published" || discoveryOrigin(manifest, page.group) !== origin ? !1 : !group || scope === "site" ? !0 : pathWithin(page.path, basePath) ? page.group === group || scope !== "self" && page.group.startsWith(`${group}/`) : !1);
|
|
30
|
+
return limit ? pages.slice(0, limit) : pages;
|
|
31
|
+
}
|
|
32
|
+
function groupDiscoveryPages({
|
|
33
|
+
manifest,
|
|
34
|
+
pages
|
|
35
|
+
}) {
|
|
36
|
+
let sections = /* @__PURE__ */ new Map();
|
|
37
|
+
for (let page of pages) {
|
|
38
|
+
let group = manifest.groups[page.group], key = group ? page.group : "", section = sections.get(key);
|
|
39
|
+
section || (section = {
|
|
40
|
+
...group ? { group: page.group } : {},
|
|
41
|
+
title: group ? group.key === "__root" ? manifest.site.name : group.title : "Pages",
|
|
42
|
+
pages: []
|
|
43
|
+
}, sections.set(key, section)), section.pages.push(page);
|
|
44
|
+
}
|
|
45
|
+
return [...sections.values()].sort(
|
|
46
|
+
(a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
|
|
47
|
+
manifest.groups[b.group ?? ""]?.path ?? "/"
|
|
48
|
+
) || a.title.localeCompare(b.title)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/lib/runtime/metadata/llms-serialization.ts
|
|
53
|
+
function inlineText(value) {
|
|
54
|
+
return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
|
|
55
|
+
}
|
|
56
|
+
function markdownLink(link) {
|
|
57
|
+
let url = link.url.replace(
|
|
58
|
+
/[\s()<>]/g,
|
|
59
|
+
(value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
|
|
60
|
+
);
|
|
61
|
+
return `[${inlineText(link.title)}](${url})`;
|
|
62
|
+
}
|
|
63
|
+
function serializeLlmsIndex(input) {
|
|
64
|
+
let body = (input.sections ?? [
|
|
65
|
+
{ title: "Pages", pages: input.pages ?? [] }
|
|
66
|
+
]).map((section) => {
|
|
67
|
+
let lines = [
|
|
68
|
+
...(section.links ?? []).map((link) => `- ${markdownLink(link)}`),
|
|
69
|
+
...section.pages.map((page) => {
|
|
70
|
+
let description = input.includeDescriptions && page.description ? `: ${inlineText(page.description)}` : "", alternate = page.alternate ? ` (${markdownLink(page.alternate)})` : "";
|
|
71
|
+
return `- ${markdownLink(page)}${alternate}${description}`;
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
return `## ${inlineText(section.title)}
|
|
75
|
+
|
|
76
|
+
${lines.join(`
|
|
77
|
+
`)}`;
|
|
78
|
+
}).join(`
|
|
79
|
+
|
|
80
|
+
`), linkLines = (input.links ?? []).map(
|
|
81
|
+
(link) => `- ${markdownLink(link)}`
|
|
82
|
+
), linkSection = linkLines.length ? `
|
|
83
|
+
|
|
84
|
+
## Group LLM indexes
|
|
85
|
+
|
|
86
|
+
${linkLines.join(`
|
|
87
|
+
`)}` : "", otherGroupLines = (input.otherGroupLinks ?? []).map(
|
|
88
|
+
(link) => `- ${markdownLink(link)}`
|
|
89
|
+
), otherGroupSection = otherGroupLines.length ? `
|
|
90
|
+
|
|
91
|
+
## Other content groups
|
|
92
|
+
|
|
93
|
+
${otherGroupLines.join(`
|
|
94
|
+
`)}` : "";
|
|
95
|
+
return `# ${inlineText(input.title)}
|
|
96
|
+
|
|
97
|
+
> ${inlineText(input.summary)}
|
|
98
|
+
|
|
99
|
+
${body}${linkSection}${otherGroupSection}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
16
103
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
104
|
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
105
|
function cacheControl(policy) {
|
|
@@ -34,62 +121,143 @@ function createCachedTextResponse(options) {
|
|
|
34
121
|
}
|
|
35
122
|
|
|
36
123
|
// src/route-metadata-sitemap.ts
|
|
124
|
+
var ROOT_CONTENT_GROUP_KEY = "__root";
|
|
37
125
|
function xmlEscape(value) {
|
|
38
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
126
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
|
|
127
|
+
}
|
|
128
|
+
function sitemapDirectory(path) {
|
|
129
|
+
return path.slice(0, path.lastIndexOf("/") + 1) || "/";
|
|
39
130
|
}
|
|
40
|
-
|
|
131
|
+
function rootMountedGroup(manifest, origin) {
|
|
132
|
+
return Object.values(manifest.groups).find(
|
|
133
|
+
(group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" && discoveryOrigin(manifest, group.key) === origin
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
async function sitemapXml(manifest, options) {
|
|
41
137
|
"use cache";
|
|
42
138
|
cacheLife("page"), cacheTag(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
|
|
43
|
-
let
|
|
44
|
-
"/"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
139
|
+
let targetGroup = options.group ? manifest.groups[options.group] : void 0, directory = sitemapDirectory(
|
|
140
|
+
options.path ?? `${targetGroup?.path === "/" ? "" : targetGroup?.path ?? ""}/sitemap.xml`
|
|
141
|
+
), origin = targetGroup ? discoveryOrigin(manifest, targetGroup.key) : manifest.site.origin;
|
|
142
|
+
if (options.sitemaps)
|
|
143
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
144
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
145
|
+
${[
|
|
146
|
+
...new Set(
|
|
147
|
+
options.sitemaps.filter(
|
|
148
|
+
(sitemap) => discoveryOrigin(manifest, sitemap.group) === origin
|
|
149
|
+
).filter(
|
|
150
|
+
(sitemap) => sitemap.path.startsWith(directory) && sitemap.path !== options.path
|
|
151
|
+
).map(
|
|
152
|
+
(sitemap) => canonicalUrl(manifest, sitemap.path, sitemap.group)
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
].map((url) => ` <sitemap><loc>${xmlEscape(url)}</loc></sitemap>`).join(`
|
|
156
|
+
`)}
|
|
157
|
+
</sitemapindex>
|
|
158
|
+
`;
|
|
159
|
+
let homeGroup = targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter(
|
|
160
|
+
(group) => discoveryOrigin(manifest, group.key) === origin && (directory === "/" || group.path.startsWith(directory))
|
|
161
|
+
), urls = [
|
|
162
|
+
{
|
|
163
|
+
path: homeGroup?.path ?? "/",
|
|
164
|
+
group: homeGroup?.key
|
|
165
|
+
},
|
|
166
|
+
...groups.map((group) => ({ path: group.path, group: group.key })),
|
|
167
|
+
...manifest.pages.filter((page) => page.status === "published").filter((page) => discoveryOrigin(manifest, page.group) === origin).map((page) => ({ path: page.path, group: page.group }))
|
|
168
|
+
].filter(
|
|
169
|
+
({ path }) => (directory === "/" || path.startsWith(directory)) && !(options.exclude ?? []).some(
|
|
170
|
+
(sitemap) => discoveryOrigin(manifest, sitemap.group) === origin && path.startsWith(sitemapDirectory(sitemap.path))
|
|
171
|
+
)
|
|
172
|
+
);
|
|
48
173
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
49
174
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
50
|
-
${[...new
|
|
51
|
-
(
|
|
52
|
-
|
|
175
|
+
${[...new Map(
|
|
176
|
+
urls.map(({ path, group }) => {
|
|
177
|
+
let url = canonicalUrl(manifest, path, group);
|
|
178
|
+
return [url, url];
|
|
179
|
+
})
|
|
180
|
+
).values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
|
|
53
181
|
`)}
|
|
54
182
|
</urlset>
|
|
55
183
|
`;
|
|
56
184
|
}
|
|
57
|
-
function createSitemapXmlRoute(manifest) {
|
|
185
|
+
function createSitemapXmlRoute(manifest, options = {}) {
|
|
58
186
|
return async function() {
|
|
59
187
|
return createCachedTextResponse({
|
|
60
|
-
body: await sitemapXml(manifest),
|
|
188
|
+
body: await sitemapXml(manifest, options),
|
|
61
189
|
contentType: "application/xml; charset=utf-8"
|
|
62
190
|
});
|
|
63
191
|
};
|
|
64
192
|
}
|
|
65
|
-
async function sitemapMarkdown(manifest, artifactManifest) {
|
|
66
|
-
let groups = Object.values(manifest.groups).
|
|
67
|
-
(group) =>
|
|
68
|
-
), pages =
|
|
69
|
-
|
|
70
|
-
|
|
193
|
+
async function sitemapMarkdown(manifest, artifactManifest, options) {
|
|
194
|
+
let origin = discoveryOrigin(manifest, options.group), targetGroup = options.group ? manifest.groups[options.group] : void 0, rootGroup = targetGroup?.key === ROOT_CONTENT_GROUP_KEY ? void 0 : targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter((group) => group.key !== ROOT_CONTENT_GROUP_KEY).filter((group) => discoveryOrigin(manifest, group.key) === origin).filter(
|
|
195
|
+
(group) => !targetGroup || options.scope === "site" || pathWithin(group.path, targetGroup.path) && (group.key === targetGroup.key || options.scope !== "self" && group.key.startsWith(`${targetGroup.key}/`))
|
|
196
|
+
), pages = discoveryPages({ manifest, ...options }).sort(
|
|
197
|
+
(a, b) => a.path.localeCompare(b.path)
|
|
198
|
+
), sections = groupDiscoveryPages({ manifest, pages });
|
|
199
|
+
for (let group of groups)
|
|
200
|
+
sections.some((section) => section.group === group.key) || sections.push({ group: group.key, title: group.title, pages: [] });
|
|
201
|
+
sections.sort(
|
|
202
|
+
(a, b) => (manifest.groups[a.group ?? ""]?.path ?? "/").localeCompare(
|
|
203
|
+
manifest.groups[b.group ?? ""]?.path ?? "/"
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
let links = options.links ?? [
|
|
207
|
+
{ title: "LLMS index", path: "/llms.txt" },
|
|
208
|
+
{ title: "Full LLMS index", path: "/llms-full.txt" },
|
|
209
|
+
{ title: "XML sitemap", path: "/sitemap.xml" }
|
|
210
|
+
];
|
|
211
|
+
return serializeLlmsIndex({
|
|
212
|
+
title: `${rootGroup?.title ?? manifest.site.name} Sitemap`,
|
|
213
|
+
summary: "Browse the published pages and their available Markdown versions.",
|
|
214
|
+
sections: [
|
|
215
|
+
...links.length ? [
|
|
216
|
+
{
|
|
217
|
+
title: "Agent indexes",
|
|
218
|
+
pages: [],
|
|
219
|
+
links: links.map((link) => ({
|
|
220
|
+
title: link.title,
|
|
221
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
222
|
+
}))
|
|
223
|
+
}
|
|
224
|
+
] : [],
|
|
225
|
+
...sections.map((section) => {
|
|
226
|
+
let group = manifest.groups[section.group ?? ""];
|
|
227
|
+
return {
|
|
228
|
+
title: section.title,
|
|
229
|
+
links: group && group.key !== ROOT_CONTENT_GROUP_KEY ? [
|
|
230
|
+
{
|
|
231
|
+
title: group.title,
|
|
232
|
+
url: canonicalUrl(manifest, group.path, group.key)
|
|
233
|
+
}
|
|
234
|
+
] : [],
|
|
235
|
+
pages: section.pages.map((page) => {
|
|
236
|
+
let markdownPath = options.markdownAlternates === !1 ? void 0 : artifactManifest.byHtmlPath[page.path];
|
|
237
|
+
return {
|
|
238
|
+
title: page.title,
|
|
239
|
+
url: canonicalUrl(manifest, page.path, page.group),
|
|
240
|
+
...markdownPath ? {
|
|
241
|
+
alternate: {
|
|
242
|
+
title: "Markdown",
|
|
243
|
+
url: canonicalUrl(manifest, markdownPath, page.group)
|
|
244
|
+
}
|
|
245
|
+
} : {}
|
|
246
|
+
};
|
|
247
|
+
})
|
|
248
|
+
};
|
|
249
|
+
})
|
|
250
|
+
],
|
|
251
|
+
otherGroupLinks: options.otherGroupLinks?.map((link) => ({
|
|
252
|
+
title: link.title,
|
|
253
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
254
|
+
}))
|
|
71
255
|
});
|
|
72
|
-
return [
|
|
73
|
-
`# ${manifest.site.name} Sitemap`,
|
|
74
|
-
"## Agent indexes",
|
|
75
|
-
`- [LLMS index](${canonicalUrl(manifest, "/llms.txt")})`,
|
|
76
|
-
`- [Full LLMS index](${canonicalUrl(manifest, "/llms-full.txt")})`,
|
|
77
|
-
`- [XML sitemap](${canonicalUrl(manifest, "/sitemap.xml")})`,
|
|
78
|
-
"## Sections",
|
|
79
|
-
groups.length ? groups.join(`
|
|
80
|
-
`) : `- [Home](${canonicalUrl(manifest, "/")})`,
|
|
81
|
-
"## Pages",
|
|
82
|
-
pages.length ? pages.join(`
|
|
83
|
-
`) : `- [Home](${canonicalUrl(manifest, "/")})`,
|
|
84
|
-
""
|
|
85
|
-
].join(`
|
|
86
|
-
|
|
87
|
-
`);
|
|
88
256
|
}
|
|
89
|
-
function createSitemapMarkdownRoute(manifest, artifactManifest) {
|
|
257
|
+
function createSitemapMarkdownRoute(manifest, artifactManifest, options = {}) {
|
|
90
258
|
return async function() {
|
|
91
259
|
return createCachedTextResponse({
|
|
92
|
-
body: await sitemapMarkdown(manifest, artifactManifest),
|
|
260
|
+
body: await sitemapMarkdown(manifest, artifactManifest, options),
|
|
93
261
|
contentType: "text/markdown; charset=utf-8"
|
|
94
262
|
});
|
|
95
263
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type NotFoundLink = {
|
|
2
|
+
title: string;
|
|
3
|
+
href: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
kind?: "sitemap" | "sitemap-md" | "llms" | "llms-full";
|
|
6
|
+
};
|
|
7
|
+
type NotFoundScope = {
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
group?: string;
|
|
11
|
+
origin?: string;
|
|
12
|
+
describedBy?: string;
|
|
13
|
+
htmlPath: string;
|
|
14
|
+
recommendations: readonly NotFoundLink[];
|
|
15
|
+
indexes: readonly NotFoundLink[];
|
|
16
|
+
markdown: string;
|
|
17
|
+
};
|
|
18
|
+
declare function resolveNotFoundScope({ scopes, pathname, }: {
|
|
19
|
+
scopes: readonly NotFoundScope[];
|
|
20
|
+
pathname: string;
|
|
21
|
+
}): NotFoundScope | undefined;
|
|
22
|
+
declare function serializeNotFoundMarkdown({ recommendations, indexes, }: {
|
|
23
|
+
recommendations: readonly NotFoundLink[];
|
|
24
|
+
indexes: readonly NotFoundLink[];
|
|
25
|
+
}): string;
|
|
26
|
+
declare function createNotFoundTextResponse({ scope, pathname, method, contentType, vary, }: {
|
|
27
|
+
scope?: NotFoundScope;
|
|
28
|
+
pathname?: string;
|
|
29
|
+
method: string;
|
|
30
|
+
contentType?: "text/markdown; charset=utf-8" | "text/plain; charset=utf-8";
|
|
31
|
+
vary?: boolean;
|
|
32
|
+
}): Response;
|
|
33
|
+
|
|
34
|
+
export { type NotFoundLink, type NotFoundScope, createNotFoundTextResponse, resolveNotFoundScope, serializeNotFoundMarkdown };
|