@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
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
// src/route-metadata-llms.ts
|
|
2
|
-
import { tags } from "@publish.os/nextjs/cache/tags";
|
|
3
|
-
import { cacheLife, cacheTag } from "next/cache";
|
|
4
|
-
|
|
5
|
-
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
|
-
function canonicalUrl(manifest, path, group) {
|
|
7
|
-
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
|
-
if (!origin) return path;
|
|
9
|
-
try {
|
|
10
|
-
return new URL(path, `${origin}/`).toString();
|
|
11
|
-
} catch {
|
|
12
|
-
return path;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
2
|
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
3
|
function cacheControl(policy) {
|
|
@@ -34,53 +19,7 @@ function createCachedTextResponse(options) {
|
|
|
34
19
|
}
|
|
35
20
|
|
|
36
21
|
// src/route-metadata-llms.ts
|
|
37
|
-
|
|
38
|
-
function byteLength(value) {
|
|
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 = {}) {
|
|
48
|
-
"use cache";
|
|
49
|
-
cacheLife("page"), cacheTag(
|
|
50
|
-
tags.site(),
|
|
51
|
-
tags.llms(options.group ?? options.scope ?? "root"),
|
|
52
|
-
tags.manifest(manifest.contentHash)
|
|
53
|
-
);
|
|
54
|
-
let pages = manifest.pages.filter((page) => page.status === "published").filter((page) => pageInScope(page, options)), lines = (options.limit ? pages.slice(0, options.limit) : pages).map((page) => {
|
|
55
|
-
let description = options.includeDescriptions && page.description ? ` - ${page.description}` : "";
|
|
56
|
-
return `- [${page.title}](${canonicalUrl(manifest, page.path, page.group)})${description}`;
|
|
57
|
-
}), linkLines = (options.links ?? []).map(
|
|
58
|
-
(link) => `- [${link.title}](${canonicalUrl(manifest, link.path, link.group)})`
|
|
59
|
-
), linkSection = linkLines.length ? `
|
|
60
|
-
|
|
61
|
-
## Group LLM indexes
|
|
62
|
-
|
|
63
|
-
${linkLines.join(`
|
|
64
|
-
`)}` : "";
|
|
65
|
-
return `# ${manifest.site.name}
|
|
66
|
-
|
|
67
|
-
${llmsSummary(manifest)}
|
|
68
|
-
|
|
69
|
-
## Pages
|
|
70
|
-
|
|
71
|
-
${lines.join(`
|
|
72
|
-
`)}${linkSection}
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
function createLlmsTxtRoute(manifest, options = {}) {
|
|
76
|
-
return async function() {
|
|
77
|
-
return createCachedTextResponse({
|
|
78
|
-
body: await llmsTxt(manifest, options),
|
|
79
|
-
contentType: "text/plain; charset=utf-8"
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function createPrecomputedLlmsTxtRoute(output) {
|
|
22
|
+
function createLlmsTxtRoute(output) {
|
|
84
23
|
return function() {
|
|
85
24
|
return createCachedTextResponse({
|
|
86
25
|
body: output.body,
|
|
@@ -88,46 +27,6 @@ function createPrecomputedLlmsTxtRoute(output) {
|
|
|
88
27
|
});
|
|
89
28
|
};
|
|
90
29
|
}
|
|
91
|
-
async function llmsFullTxt(manifest, artifacts, options = {}) {
|
|
92
|
-
let maxBytes = options.maxBytes ?? DEFAULT_LLMS_FULL_MAX_BYTES, header = `# ${manifest.site.name} Full Content
|
|
93
|
-
|
|
94
|
-
> LLMS index: ${canonicalUrl(manifest, "/llms.txt")}
|
|
95
|
-
> Sitemap: ${canonicalUrl(manifest, "/sitemap.md")}
|
|
96
|
-
|
|
97
|
-
`, sections = [], totalBytes = byteLength(header), included = 0, truncated = !1;
|
|
98
|
-
for (let artifact of Object.values(artifacts).sort(
|
|
99
|
-
(a, b) => a.markdownPath.localeCompare(b.markdownPath)
|
|
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}`;
|
|
116
|
-
}
|
|
117
|
-
async function llmsFullTxtResponse(manifest, artifacts, options = {}) {
|
|
118
|
-
return createCachedTextResponse({
|
|
119
|
-
body: await llmsFullTxt(manifest, artifacts, options),
|
|
120
|
-
contentType: "text/plain; charset=utf-8"
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function createLlmsFullTxtRoute(manifest, artifacts, options = {}) {
|
|
124
|
-
return async function() {
|
|
125
|
-
return llmsFullTxtResponse(manifest, artifacts, options);
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
30
|
export {
|
|
129
|
-
|
|
130
|
-
createLlmsTxtRoute,
|
|
131
|
-
createPrecomputedLlmsTxtRoute,
|
|
132
|
-
llmsFullTxtResponse
|
|
31
|
+
createLlmsTxtRoute
|
|
133
32
|
};
|
|
@@ -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",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare function createRobotsTxtRoute(defaultOutput: {
|
|
2
|
+
body: string;
|
|
3
|
+
}, outputsByOrigin?: Record<string, {
|
|
4
|
+
body: string;
|
|
5
|
+
}>): (request: Request) => Response;
|
|
4
6
|
|
|
5
7
|
export { createRobotsTxtRoute };
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
// src/route-metadata-robots.ts
|
|
2
|
-
import { tags } from "@publish.os/nextjs/cache/tags";
|
|
3
|
-
import { cacheLife, cacheTag } from "next/cache";
|
|
4
|
-
|
|
5
|
-
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
|
-
function canonicalUrl(manifest, path, group) {
|
|
7
|
-
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
|
-
if (!origin) return path;
|
|
9
|
-
try {
|
|
10
|
-
return new URL(path, `${origin}/`).toString();
|
|
11
|
-
} catch {
|
|
12
|
-
return path;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
2
|
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
3
|
function cacheControl(policy) {
|
|
@@ -34,17 +19,11 @@ function createCachedTextResponse(options) {
|
|
|
34
19
|
}
|
|
35
20
|
|
|
36
21
|
// src/route-metadata-robots.ts
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Allow: /
|
|
41
|
-
Sitemap: ${canonicalUrl(manifest, "/sitemap.xml")}
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
function createRobotsTxtRoute(manifest) {
|
|
45
|
-
return async function() {
|
|
22
|
+
function createRobotsTxtRoute(defaultOutput, outputsByOrigin = {}) {
|
|
23
|
+
return function(request) {
|
|
24
|
+
let output = outputsByOrigin[new URL(request.url).origin] ?? defaultOutput;
|
|
46
25
|
return createCachedTextResponse({
|
|
47
|
-
body:
|
|
26
|
+
body: output.body,
|
|
48
27
|
contentType: "text/plain; charset=utf-8"
|
|
49
28
|
});
|
|
50
29
|
};
|
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
import { MarkdownRouteArtifactManifest } from '../agent/markdown.js';
|
|
2
|
-
import { M as ManifestLike } from '../../../types-
|
|
2
|
+
import { M as ManifestLike } from '../../../types-BbqmOzLC.js';
|
|
3
|
+
import '../not-found.js';
|
|
3
4
|
|
|
5
|
+
type SitemapReference = {
|
|
6
|
+
path: string;
|
|
7
|
+
group?: string;
|
|
8
|
+
};
|
|
4
9
|
type SitemapRouteOptions = {
|
|
5
10
|
group?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
includeUrls?: SitemapReference[];
|
|
13
|
+
sitemaps?: SitemapReference[];
|
|
14
|
+
exclude?: SitemapReference[];
|
|
15
|
+
};
|
|
16
|
+
type SitemapMarkdownRouteOptions = {
|
|
17
|
+
group?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
scope?: "site" | "group" | "self";
|
|
20
|
+
excludeGroups?: string[];
|
|
21
|
+
includeUrls?: Array<{
|
|
22
|
+
path?: string;
|
|
23
|
+
group?: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}>;
|
|
26
|
+
groupSitemaps?: Array<SitemapReference & {
|
|
27
|
+
title: string;
|
|
28
|
+
}>;
|
|
29
|
+
parts?: Array<SitemapReference & {
|
|
30
|
+
title: string;
|
|
31
|
+
}>;
|
|
32
|
+
links?: Array<SitemapReference & {
|
|
33
|
+
title: string;
|
|
34
|
+
}>;
|
|
35
|
+
otherGroupLinks?: Array<SitemapReference & {
|
|
36
|
+
title: string;
|
|
37
|
+
}>;
|
|
38
|
+
markdownAlternates?: boolean;
|
|
6
39
|
};
|
|
7
40
|
declare function createSitemapXmlRoute(manifest: ManifestLike, options?: SitemapRouteOptions): () => Promise<Response>;
|
|
8
|
-
declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest): () => Promise<Response>;
|
|
41
|
+
declare function createSitemapMarkdownRoute(manifest: ManifestLike, artifactManifest: MarkdownRouteArtifactManifest, options?: SitemapMarkdownRouteOptions): () => Promise<Response>;
|
|
9
42
|
|
|
10
|
-
export { type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
|
|
43
|
+
export { type SitemapMarkdownRouteOptions, type SitemapRouteOptions, createSitemapMarkdownRoute, createSitemapXmlRoute };
|
|
@@ -5,7 +5,8 @@ import { cacheLife, cacheTag } from "next/cache";
|
|
|
5
5
|
// src/lib/runtime/metadata/canonical-url.ts
|
|
6
6
|
function canonicalUrl(manifest, path, group) {
|
|
7
7
|
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
8
|
-
if (!origin)
|
|
8
|
+
if (!origin)
|
|
9
|
+
return /^[a-z][a-z\d+.-]*:/i.test(path) ? path : new URL(path, "https://publish.invalid").pathname;
|
|
9
10
|
try {
|
|
10
11
|
return new URL(path, `${origin}/`).toString();
|
|
11
12
|
} catch {
|
|
@@ -13,6 +14,111 @@ function canonicalUrl(manifest, path, group) {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
// src/lib/runtime/metadata/discovery-content.ts
|
|
18
|
+
function discoveryOrigin(manifest, group) {
|
|
19
|
+
return (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin;
|
|
20
|
+
}
|
|
21
|
+
function navigationDiscoverySections({
|
|
22
|
+
manifest,
|
|
23
|
+
group,
|
|
24
|
+
scope,
|
|
25
|
+
limit,
|
|
26
|
+
excludeGroups = [],
|
|
27
|
+
markdownPaths
|
|
28
|
+
}) {
|
|
29
|
+
let origin = discoveryOrigin(manifest, group), targetGroup = group ? manifest.groups[group] : void 0, mountedGroup = Object.values(manifest.groups).find(
|
|
30
|
+
(candidate) => candidate.key !== "__root" && candidate.path === "/" && discoveryOrigin(manifest, candidate.key) === origin
|
|
31
|
+
), rootGroups = targetGroup && scope !== "site" ? [manifest.groups[targetGroup.navigation.rootGroup]] : Object.values(manifest.groups).filter(
|
|
32
|
+
(candidate) => candidate.key === candidate.navigation.rootGroup && (candidate.key !== "__root" || !mountedGroup) && discoveryOrigin(manifest, candidate.key) === origin
|
|
33
|
+
), sections = [], pageKeys = /* @__PURE__ */ new Set(), pageCount = 0, inScope = (entryGroup) => discoveryOrigin(manifest, entryGroup) !== origin || excludeGroups.some(
|
|
34
|
+
(excluded) => entryGroup === excluded || entryGroup.startsWith(`${excluded}/`)
|
|
35
|
+
) ? !1 : !targetGroup || scope === "site" ? !0 : entryGroup === targetGroup.key || scope !== "self" && entryGroup.startsWith(`${targetGroup.key}/`), append = (title, entry) => {
|
|
36
|
+
let previous = sections.at(-1);
|
|
37
|
+
previous?.title === title ? previous.entries.push(entry) : sections.push({ title, entries: [entry] });
|
|
38
|
+
}, visit = (nodes, groupKey, headings) => {
|
|
39
|
+
for (let node of nodes)
|
|
40
|
+
if (node.type === "page") {
|
|
41
|
+
let page = node.page, key = `${page.group}/${page.fileID}`;
|
|
42
|
+
if (page.frontmatter.status !== "published" || !inScope(page.group) || pageKeys.has(key) || limit !== void 0 && limit > 0 && pageCount >= limit)
|
|
43
|
+
continue;
|
|
44
|
+
pageKeys.add(key), pageCount += 1, append(headings.join(" > "), {
|
|
45
|
+
type: "page",
|
|
46
|
+
title: node.label || page.frontmatter.title,
|
|
47
|
+
url: canonicalUrl(
|
|
48
|
+
manifest,
|
|
49
|
+
markdownPaths?.get(page.path) ?? page.path,
|
|
50
|
+
page.group
|
|
51
|
+
),
|
|
52
|
+
path: page.path,
|
|
53
|
+
group: page.group,
|
|
54
|
+
...page.frontmatter.description ? { description: page.frontmatter.description } : {}
|
|
55
|
+
}), node.children && visit(node.children, page.group, headings);
|
|
56
|
+
} else node.type === "group" ? (inScope(node.groupKey) && append(headings.join(" > "), {
|
|
57
|
+
type: "link",
|
|
58
|
+
title: node.label,
|
|
59
|
+
url: canonicalUrl(manifest, node.route, node.groupKey),
|
|
60
|
+
group: node.groupKey
|
|
61
|
+
}), visit(node.children, node.groupKey, [...headings, node.label])) : node.type === "link" ? inScope(groupKey) && append(headings.join(" > "), {
|
|
62
|
+
type: "link",
|
|
63
|
+
title: node.label,
|
|
64
|
+
url: canonicalUrl(manifest, node.href, groupKey),
|
|
65
|
+
group: groupKey
|
|
66
|
+
}) : node.type === "section" || node.type === "folder" ? visit(node.children, groupKey, [...headings, node.label]) : node.type === "view" && visit(node.items, groupKey, headings);
|
|
67
|
+
};
|
|
68
|
+
for (let root of rootGroups)
|
|
69
|
+
!root || discoveryOrigin(manifest, root.key) !== origin || (!targetGroup || scope === "site" ? append(root.title, {
|
|
70
|
+
type: "link",
|
|
71
|
+
title: root.title,
|
|
72
|
+
url: canonicalUrl(manifest, root.path, root.key),
|
|
73
|
+
group: root.key
|
|
74
|
+
}) : root.key === targetGroup.key && append(root.title, {
|
|
75
|
+
type: "link",
|
|
76
|
+
title: root.title,
|
|
77
|
+
url: canonicalUrl(manifest, root.path, root.key),
|
|
78
|
+
group: root.key
|
|
79
|
+
}), visit(root.navigation.items, root.key, [root.title]));
|
|
80
|
+
return sections;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/lib/runtime/metadata/llms-serialization.ts
|
|
84
|
+
function inlineText(value) {
|
|
85
|
+
return value.replace(/[\r\n]+/g, " ").replace(/([\\`*_[\]<>])/g, "\\$1");
|
|
86
|
+
}
|
|
87
|
+
function markdownLink(link) {
|
|
88
|
+
let url = link.url.replace(
|
|
89
|
+
/[\s()<>]/g,
|
|
90
|
+
(value) => value === "(" ? "%28" : value === ")" ? "%29" : encodeURIComponent(value)
|
|
91
|
+
);
|
|
92
|
+
return `[${inlineText(link.title)}](${url})`;
|
|
93
|
+
}
|
|
94
|
+
function serializeLlmsIndex(input) {
|
|
95
|
+
let body = (input.sections ?? []).map((section) => {
|
|
96
|
+
let lines = section.entries.map((entry) => {
|
|
97
|
+
let description = input.includeDescriptions && entry.description ? `: ${inlineText(entry.description)}` : "", alternate = entry.alternate ? ` (${markdownLink(entry.alternate)})` : "";
|
|
98
|
+
return `- ${markdownLink(entry)}${alternate}${description}`;
|
|
99
|
+
});
|
|
100
|
+
return `## ${inlineText(section.title)}
|
|
101
|
+
|
|
102
|
+
${lines.join(`
|
|
103
|
+
`)}`;
|
|
104
|
+
}).join(`
|
|
105
|
+
|
|
106
|
+
`), otherGroupLines = (input.otherGroupLinks ?? []).map(
|
|
107
|
+
(link) => `- ${markdownLink(link)}`
|
|
108
|
+
), otherGroupSection = otherGroupLines.length ? `
|
|
109
|
+
|
|
110
|
+
## Other content groups
|
|
111
|
+
|
|
112
|
+
${otherGroupLines.join(`
|
|
113
|
+
`)}` : "";
|
|
114
|
+
return `# ${inlineText(input.title)}
|
|
115
|
+
|
|
116
|
+
> ${inlineText(input.summary)}
|
|
117
|
+
|
|
118
|
+
${body}${otherGroupSection}
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
|
|
16
122
|
// src/lib/runtime/response/cached-text-response.ts
|
|
17
123
|
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
124
|
function cacheControl(policy) {
|
|
@@ -35,44 +141,94 @@ function createCachedTextResponse(options) {
|
|
|
35
141
|
|
|
36
142
|
// src/route-metadata-sitemap.ts
|
|
37
143
|
var ROOT_CONTENT_GROUP_KEY = "__root";
|
|
144
|
+
function assertSitemapSize(options) {
|
|
145
|
+
let bytes = new TextEncoder().encode(options.body).byteLength;
|
|
146
|
+
if (options.entryCount > 5e4 || bytes > 52428800)
|
|
147
|
+
throw new RangeError(
|
|
148
|
+
`Generated sitemap "${options.path}" exceeds ${5e4} entries or ${52428800} UTF-8 bytes. Split or limit its content.`
|
|
149
|
+
);
|
|
150
|
+
return options.body;
|
|
151
|
+
}
|
|
38
152
|
function xmlEscape(value) {
|
|
39
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
153
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
|
|
40
154
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
155
|
+
function sitemapDirectory(path) {
|
|
156
|
+
return path.slice(0, path.lastIndexOf("/") + 1) || "/";
|
|
43
157
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
158
|
+
function isWithinDirectory(path, directories) {
|
|
159
|
+
for (let end = path.indexOf("/"); end >= 0; end = path.indexOf("/", end + 1))
|
|
160
|
+
if (directories.has(path.slice(0, end + 1))) return !0;
|
|
161
|
+
return !1;
|
|
46
162
|
}
|
|
47
163
|
function rootMountedGroup(manifest, origin) {
|
|
48
164
|
return Object.values(manifest.groups).find(
|
|
49
|
-
(group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" &&
|
|
165
|
+
(group) => group.key !== ROOT_CONTENT_GROUP_KEY && group.path === "/" && discoveryOrigin(manifest, group.key) === origin
|
|
50
166
|
);
|
|
51
167
|
}
|
|
52
168
|
async function sitemapXml(manifest, options) {
|
|
53
169
|
"use cache";
|
|
54
170
|
cacheLife("page"), cacheTag(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
|
|
55
|
-
let targetGroup = options.group ? manifest.groups[options.group] : void 0,
|
|
56
|
-
|
|
171
|
+
let targetGroup = options.group ? manifest.groups[options.group] : void 0, directory = sitemapDirectory(
|
|
172
|
+
options.path ?? `${targetGroup?.path === "/" ? "" : targetGroup?.path ?? ""}/sitemap.xml`
|
|
173
|
+
), origin = targetGroup ? discoveryOrigin(manifest, targetGroup.key) : manifest.site.origin, includedUrls = options.includeUrls ? new Set(
|
|
174
|
+
options.includeUrls.map(
|
|
175
|
+
({ path, group }) => JSON.stringify([group ?? null, path])
|
|
176
|
+
)
|
|
177
|
+
) : void 0, excludedDirectories = new Set(
|
|
178
|
+
(options.exclude ?? []).filter((sitemap) => discoveryOrigin(manifest, sitemap.group) === origin).map((sitemap) => sitemapDirectory(sitemap.path))
|
|
179
|
+
);
|
|
180
|
+
if (options.sitemaps) {
|
|
181
|
+
let urls2 = [
|
|
182
|
+
...new Set(
|
|
183
|
+
options.sitemaps.filter(
|
|
184
|
+
(sitemap) => discoveryOrigin(manifest, sitemap.group) === origin
|
|
185
|
+
).filter(
|
|
186
|
+
(sitemap) => sitemap.path.startsWith(directory) && sitemap.path !== options.path
|
|
187
|
+
).map(
|
|
188
|
+
(sitemap) => canonicalUrl(manifest, sitemap.path, sitemap.group)
|
|
189
|
+
)
|
|
190
|
+
)
|
|
191
|
+
], body2 = urls2.map((url) => ` <sitemap><loc>${xmlEscape(url)}</loc></sitemap>`).join(`
|
|
192
|
+
`);
|
|
193
|
+
return assertSitemapSize({
|
|
194
|
+
path: options.path ?? "/sitemap.xml",
|
|
195
|
+
entryCount: urls2.length,
|
|
196
|
+
body: `<?xml version="1.0" encoding="UTF-8"?>
|
|
197
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
198
|
+
${body2}
|
|
199
|
+
</sitemapindex>
|
|
200
|
+
`
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
let homeGroup = targetGroup ?? rootMountedGroup(manifest, origin), groups = Object.values(manifest.groups).filter(
|
|
204
|
+
(group) => discoveryOrigin(manifest, group.key) === origin && (directory === "/" || group.path.startsWith(directory))
|
|
57
205
|
), urls = [
|
|
58
206
|
{
|
|
59
207
|
path: homeGroup?.path ?? "/",
|
|
60
208
|
group: homeGroup?.key
|
|
61
209
|
},
|
|
62
210
|
...groups.map((group) => ({ path: group.path, group: group.key })),
|
|
63
|
-
...manifest.pages.filter(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
211
|
+
...manifest.pages.filter(
|
|
212
|
+
(page) => page.frontmatter.status === "published" && page.frontmatter.metadata.robots?.index !== !1
|
|
213
|
+
).filter((page) => discoveryOrigin(manifest, page.group) === origin).map((page) => ({ path: page.path, group: page.group }))
|
|
214
|
+
].filter(
|
|
215
|
+
({ path, group }) => (directory === "/" || path.startsWith(directory)) && (!includedUrls || includedUrls.has(JSON.stringify([group ?? null, path]))) && !isWithinDirectory(path, excludedDirectories)
|
|
216
|
+
), uniqueUrls = new Map(
|
|
68
217
|
urls.map(({ path, group }) => {
|
|
69
218
|
let url = canonicalUrl(manifest, path, group);
|
|
70
219
|
return [url, url];
|
|
71
220
|
})
|
|
72
|
-
).values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
|
|
73
|
-
`)
|
|
221
|
+
), body = [...uniqueUrls.values()].map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join(`
|
|
222
|
+
`);
|
|
223
|
+
return assertSitemapSize({
|
|
224
|
+
path: options.path ?? "/sitemap.xml",
|
|
225
|
+
entryCount: uniqueUrls.size,
|
|
226
|
+
body: `<?xml version="1.0" encoding="UTF-8"?>
|
|
227
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
228
|
+
${body}
|
|
74
229
|
</urlset>
|
|
75
|
-
|
|
230
|
+
`
|
|
231
|
+
});
|
|
76
232
|
}
|
|
77
233
|
function createSitemapXmlRoute(manifest, options = {}) {
|
|
78
234
|
return async function() {
|
|
@@ -82,42 +238,114 @@ function createSitemapXmlRoute(manifest, options = {}) {
|
|
|
82
238
|
});
|
|
83
239
|
};
|
|
84
240
|
}
|
|
85
|
-
async function sitemapMarkdown(manifest, artifactManifest) {
|
|
86
|
-
let origin =
|
|
87
|
-
|
|
88
|
-
),
|
|
89
|
-
|
|
90
|
-
|
|
241
|
+
async function sitemapMarkdown(manifest, artifactManifest, options) {
|
|
242
|
+
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), markdownPaths = new Map(
|
|
243
|
+
options.markdownAlternates === !1 ? [] : Object.entries(artifactManifest.byHtmlPath)
|
|
244
|
+
), linkedParts = options.parts ?? [], groupSitemaps = options.groupSitemaps ?? [], discoverySections = linkedParts.length ? [] : navigationDiscoverySections({
|
|
245
|
+
manifest,
|
|
246
|
+
...options,
|
|
247
|
+
markdownPaths
|
|
248
|
+
}), selectors = options.includeUrls, remainingSelectors = /* @__PURE__ */ new Map(), selectorKeys = /* @__PURE__ */ new Map();
|
|
249
|
+
for (let [index, selector] of (selectors ?? []).entries()) {
|
|
250
|
+
let keys = /* @__PURE__ */ new Set();
|
|
251
|
+
selector.path !== void 0 && (keys.add(
|
|
252
|
+
`page:${JSON.stringify([selector.group ?? null, selector.path])}`
|
|
253
|
+
), keys.add(
|
|
254
|
+
`url:${JSON.stringify([
|
|
255
|
+
selector.group ?? null,
|
|
256
|
+
canonicalUrl(manifest, selector.path, selector.group)
|
|
257
|
+
])}`
|
|
258
|
+
)), selector.url !== void 0 && keys.add(`url:${JSON.stringify([selector.group ?? null, selector.url])}`), selectorKeys.set(index, [...keys]);
|
|
259
|
+
for (let key of keys) {
|
|
260
|
+
let candidates = remainingSelectors.get(key) ?? /* @__PURE__ */ new Set();
|
|
261
|
+
candidates.add(index), remainingSelectors.set(key, candidates);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
let selectedSections = discoverySections.map((section) => ({
|
|
265
|
+
...section,
|
|
266
|
+
entries: section.entries.filter((entry) => {
|
|
267
|
+
if (!selectors) return !0;
|
|
268
|
+
let key = entry.type === "page" ? `page:${JSON.stringify([entry.group ?? null, entry.path])}` : `url:${JSON.stringify([entry.group ?? null, entry.url])}`, selectorIndex = remainingSelectors.get(key)?.values().next().value;
|
|
269
|
+
if (selectorIndex === void 0) return !1;
|
|
270
|
+
for (let selectorKey of selectorKeys.get(selectorIndex) ?? []) {
|
|
271
|
+
let selectorCandidates = remainingSelectors.get(selectorKey);
|
|
272
|
+
selectorCandidates?.delete(selectorIndex), selectorCandidates?.size === 0 && remainingSelectors.delete(selectorKey);
|
|
273
|
+
}
|
|
274
|
+
return !0;
|
|
275
|
+
})
|
|
276
|
+
})).filter((section) => section.entries.length > 0), links = options.links ?? [
|
|
277
|
+
{ title: "LLMS index", path: "/llms.txt" },
|
|
278
|
+
{ title: "Full LLMS index", path: "/llms-full.txt" },
|
|
279
|
+
{ title: "XML sitemap", path: "/sitemap.xml" }
|
|
280
|
+
], body = serializeLlmsIndex({
|
|
281
|
+
title: `${rootGroup?.title ?? manifest.site.name} Sitemap`,
|
|
282
|
+
summary: "Browse the published pages and their available Markdown versions.",
|
|
283
|
+
sections: [
|
|
284
|
+
...groupSitemaps.length ? [
|
|
285
|
+
{
|
|
286
|
+
title: "Content groups",
|
|
287
|
+
entries: groupSitemaps.map((sitemap) => ({
|
|
288
|
+
title: sitemap.title,
|
|
289
|
+
url: canonicalUrl(manifest, sitemap.path, sitemap.group)
|
|
290
|
+
}))
|
|
291
|
+
}
|
|
292
|
+
] : [],
|
|
293
|
+
...linkedParts.length ? [
|
|
294
|
+
{
|
|
295
|
+
title: "Parts",
|
|
296
|
+
entries: linkedParts.map((part) => ({
|
|
297
|
+
title: part.title,
|
|
298
|
+
url: canonicalUrl(manifest, part.path, part.group)
|
|
299
|
+
}))
|
|
300
|
+
}
|
|
301
|
+
] : [],
|
|
302
|
+
...links.length ? [
|
|
303
|
+
{
|
|
304
|
+
title: "Agent indexes",
|
|
305
|
+
entries: links.map((link) => ({
|
|
306
|
+
title: link.title,
|
|
307
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
308
|
+
}))
|
|
309
|
+
}
|
|
310
|
+
] : [],
|
|
311
|
+
...selectedSections.map((section) => ({
|
|
312
|
+
title: section.title,
|
|
313
|
+
entries: section.entries.map((entry) => {
|
|
314
|
+
if (entry.type === "link") return entry;
|
|
315
|
+
let markdownPath = markdownPaths.get(entry.path);
|
|
316
|
+
return {
|
|
317
|
+
title: entry.title,
|
|
318
|
+
url: canonicalUrl(manifest, entry.path, entry.group),
|
|
319
|
+
...markdownPath ? {
|
|
320
|
+
alternate: {
|
|
321
|
+
title: "Markdown",
|
|
322
|
+
url: canonicalUrl(manifest, markdownPath, entry.group)
|
|
323
|
+
}
|
|
324
|
+
} : {}
|
|
325
|
+
};
|
|
326
|
+
})
|
|
327
|
+
})),
|
|
328
|
+
...options.otherGroupLinks?.length ? [
|
|
329
|
+
{
|
|
330
|
+
title: "Other content groups",
|
|
331
|
+
entries: options.otherGroupLinks.map((link) => ({
|
|
332
|
+
title: link.title,
|
|
333
|
+
url: canonicalUrl(manifest, link.path, link.group)
|
|
334
|
+
}))
|
|
335
|
+
}
|
|
336
|
+
] : []
|
|
337
|
+
]
|
|
338
|
+
});
|
|
339
|
+
return assertSitemapSize({
|
|
340
|
+
path: options.path ?? (options.group ? `${manifest.groups[options.group]?.path ?? ""}/sitemap.md` : "/sitemap.md"),
|
|
341
|
+
entryCount: (body.match(/\]\(/g) ?? []).length,
|
|
342
|
+
body
|
|
91
343
|
});
|
|
92
|
-
return [
|
|
93
|
-
`# ${rootGroup?.title ?? manifest.site.name} Sitemap`,
|
|
94
|
-
"## Agent indexes",
|
|
95
|
-
`- [LLMS index](${canonicalUrl(manifest, "/llms.txt")})`,
|
|
96
|
-
`- [Full LLMS index](${canonicalUrl(manifest, "/llms-full.txt")})`,
|
|
97
|
-
`- [XML sitemap](${canonicalUrl(manifest, "/sitemap.xml")})`,
|
|
98
|
-
"## Sections",
|
|
99
|
-
groups.length ? groups.join(`
|
|
100
|
-
`) : `- [${rootGroup?.title ?? "Home"}](${canonicalUrl(
|
|
101
|
-
manifest,
|
|
102
|
-
rootGroup?.path ?? "/",
|
|
103
|
-
rootGroup?.key
|
|
104
|
-
)})`,
|
|
105
|
-
"## Pages",
|
|
106
|
-
pages.length ? pages.join(`
|
|
107
|
-
`) : `- [${rootGroup?.title ?? "Home"}](${canonicalUrl(
|
|
108
|
-
manifest,
|
|
109
|
-
rootGroup?.path ?? "/",
|
|
110
|
-
rootGroup?.key
|
|
111
|
-
)})`,
|
|
112
|
-
""
|
|
113
|
-
].join(`
|
|
114
|
-
|
|
115
|
-
`);
|
|
116
344
|
}
|
|
117
|
-
function createSitemapMarkdownRoute(manifest, artifactManifest) {
|
|
345
|
+
function createSitemapMarkdownRoute(manifest, artifactManifest, options = {}) {
|
|
118
346
|
return async function() {
|
|
119
347
|
return createCachedTextResponse({
|
|
120
|
-
body: await sitemapMarkdown(manifest, artifactManifest),
|
|
348
|
+
body: await sitemapMarkdown(manifest, artifactManifest, options),
|
|
121
349
|
contentType: "text/markdown; charset=utf-8"
|
|
122
350
|
});
|
|
123
351
|
};
|
|
@@ -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 };
|