@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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// src/lib/runtime/response/cached-text-response.ts
|
|
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";
|
|
3
|
+
function cacheControl(policy) {
|
|
4
|
+
return !policy || policy === "default" ? CACHE_CONTROL : policy === "short" ? SHORT_CACHE_CONTROL : policy;
|
|
5
|
+
}
|
|
6
|
+
function cdnCacheControl(policy) {
|
|
7
|
+
return !policy || policy === "default" ? CDN_CACHE_CONTROL : policy === "short" ? SHORT_CDN_CACHE_CONTROL : policy;
|
|
8
|
+
}
|
|
9
|
+
function cachedTextHeaders(contentType, options = {}) {
|
|
10
|
+
let headers = new Headers(options.headers);
|
|
11
|
+
return headers.set("cache-control", cacheControl(options.cachePolicy)), headers.set("cdn-cache-control", cdnCacheControl(options.cachePolicy)), headers.set("vercel-cdn-cache-control", cdnCacheControl(options.cachePolicy)), headers.set("content-type", contentType), headers.set("x-content-type-options", "nosniff"), options.noindex && headers.set("x-robots-tag", "noindex"), headers;
|
|
12
|
+
}
|
|
13
|
+
function createCachedTextResponse(options) {
|
|
14
|
+
let status = options.status ?? 200, method = options.method ?? "GET", headers = cachedTextHeaders(options.contentType, options);
|
|
15
|
+
return new Response(method === "HEAD" ? null : options.body, {
|
|
16
|
+
headers,
|
|
17
|
+
status
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/route-not-found.ts
|
|
22
|
+
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({
|
|
23
|
+
recommendations: [],
|
|
24
|
+
indexes: []
|
|
25
|
+
});
|
|
26
|
+
function normalizePublicPath(pathname) {
|
|
27
|
+
let path = pathname.split(/[?#]/u, 1)[0];
|
|
28
|
+
if (!path?.startsWith("/") || path.startsWith("//") || path.length > MAX_PATH_LENGTH || UNSAFE_PATH_CHARACTERS.test(path))
|
|
29
|
+
return;
|
|
30
|
+
let segments = [];
|
|
31
|
+
for (let segment of path.split("/")) {
|
|
32
|
+
if (!segment) continue;
|
|
33
|
+
let decoded;
|
|
34
|
+
try {
|
|
35
|
+
decoded = decodeURIComponent(segment);
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (decoded === "." || decoded === ".." || /[/\\]/u.test(decoded) || /%[\da-f]{2}/iu.test(decoded) || UNSAFE_PATH_CHARACTERS.test(decoded))
|
|
40
|
+
return;
|
|
41
|
+
segments.push(decoded);
|
|
42
|
+
}
|
|
43
|
+
return `/${segments.join("/")}`;
|
|
44
|
+
}
|
|
45
|
+
function containsPath({ parent, path }) {
|
|
46
|
+
return parent === "/" || path === parent || path.startsWith(`${parent}/`);
|
|
47
|
+
}
|
|
48
|
+
function missingPagePath(pathname) {
|
|
49
|
+
let normalized = normalizePublicPath(pathname);
|
|
50
|
+
if (!normalized) return;
|
|
51
|
+
let path = normalized.endsWith(".md") ? normalized.slice(0, -3) || "/" : normalized;
|
|
52
|
+
return INTERNAL_PATHS.some((parent) => containsPath({ parent, path })) ? void 0 : path;
|
|
53
|
+
}
|
|
54
|
+
function resolveNotFoundScope({
|
|
55
|
+
scopes,
|
|
56
|
+
pathname
|
|
57
|
+
}) {
|
|
58
|
+
let path = missingPagePath(pathname);
|
|
59
|
+
if (!path) return;
|
|
60
|
+
let matched, matchedLength = -1;
|
|
61
|
+
for (let scope of scopes) {
|
|
62
|
+
let scopePath = normalizePublicPath(scope.path);
|
|
63
|
+
!scopePath || !containsPath({ parent: scopePath, path }) || (scopePath.length > matchedLength || scopePath.length === matchedLength && scope.group && !matched?.group) && (matched = scope, matchedLength = scopePath.length);
|
|
64
|
+
}
|
|
65
|
+
return matched;
|
|
66
|
+
}
|
|
67
|
+
function trustedHostname(origin) {
|
|
68
|
+
if (origin)
|
|
69
|
+
try {
|
|
70
|
+
let url = new URL(origin);
|
|
71
|
+
return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : url.host.replace(/`/gu, "%60");
|
|
72
|
+
} catch {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function requestExplanation({
|
|
77
|
+
pathname,
|
|
78
|
+
origin
|
|
79
|
+
}) {
|
|
80
|
+
let path = pathname.split("/").map(encodeURIComponent).join("/"), hostname = trustedHostname(origin);
|
|
81
|
+
return `No page exists at \`${path}\`${hostname ? ` on ${hostname}` : ""}.`;
|
|
82
|
+
}
|
|
83
|
+
function indexKind(link) {
|
|
84
|
+
if (link.kind) return link.kind;
|
|
85
|
+
switch (link.title) {
|
|
86
|
+
case "Sitemap":
|
|
87
|
+
return "sitemap";
|
|
88
|
+
case "Markdown sitemap":
|
|
89
|
+
return "sitemap-md";
|
|
90
|
+
case "llms.txt":
|
|
91
|
+
case "LLMS index":
|
|
92
|
+
return "llms";
|
|
93
|
+
case "llms-full.txt":
|
|
94
|
+
return "llms-full";
|
|
95
|
+
default:
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function publicRecoveryHref(href) {
|
|
100
|
+
if (href.includes("\\") || UNSAFE_PATH_CHARACTERS.test(href))
|
|
101
|
+
return;
|
|
102
|
+
let relative = href.startsWith("/") && !href.startsWith("//");
|
|
103
|
+
try {
|
|
104
|
+
let url = new URL(
|
|
105
|
+
href,
|
|
106
|
+
relative ? "https://publishos.invalid" : void 0
|
|
107
|
+
);
|
|
108
|
+
return !["http:", "https:"].includes(url.protocol) || url.username || url.password ? void 0 : relative ? `${url.pathname}${url.search}${url.hash}` : url.href;
|
|
109
|
+
} catch {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function markdownText(value) {
|
|
114
|
+
return value.replace(/\s+/gu, " ").replace(/[\p{Cc}\p{Cs}]/gu, "").trim().replace(/[\\`*_[\]{}<>|~]/gu, "\\$&");
|
|
115
|
+
}
|
|
116
|
+
function markdownLink(link) {
|
|
117
|
+
let title = markdownText(link.title), href = publicRecoveryHref(link.href)?.replace(
|
|
118
|
+
/[()`<>]/gu,
|
|
119
|
+
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
|
|
120
|
+
);
|
|
121
|
+
if (!title || !href) return;
|
|
122
|
+
let description = link.description ? markdownText(link.description) : void 0;
|
|
123
|
+
return `- [${title}](${href})${description ? `: ${description}` : ""}`;
|
|
124
|
+
}
|
|
125
|
+
function serializeNotFoundMarkdown({
|
|
126
|
+
recommendations,
|
|
127
|
+
indexes
|
|
128
|
+
}) {
|
|
129
|
+
let sections = [
|
|
130
|
+
{ title: "Recommendations", links: recommendations },
|
|
131
|
+
{ title: "For crawlers and agents", links: indexes }
|
|
132
|
+
], lines = [
|
|
133
|
+
"# 404 \u2014 Not Found",
|
|
134
|
+
"",
|
|
135
|
+
"This page does not exist. Please check the URL and try again.",
|
|
136
|
+
""
|
|
137
|
+
];
|
|
138
|
+
for (let section of sections) {
|
|
139
|
+
let links = section.links.map(markdownLink).filter((link) => link !== void 0);
|
|
140
|
+
links.length && lines.push(`## ${section.title}`, "", ...links, "");
|
|
141
|
+
}
|
|
142
|
+
return lines.join(`
|
|
143
|
+
`);
|
|
144
|
+
}
|
|
145
|
+
function discoveryHeaders(scope) {
|
|
146
|
+
let headers = new Headers(), links = [];
|
|
147
|
+
for (let link of scope?.indexes ?? []) {
|
|
148
|
+
let kind = indexKind(link), href = /[\s<>"\\]/u.test(link.href) ? void 0 : publicRecoveryHref(link.href);
|
|
149
|
+
if (!(!kind || !href))
|
|
150
|
+
switch (kind) {
|
|
151
|
+
case "llms":
|
|
152
|
+
if (scope?.describedBy !== void 0) break;
|
|
153
|
+
links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href);
|
|
154
|
+
break;
|
|
155
|
+
case "llms-full":
|
|
156
|
+
links.push(
|
|
157
|
+
`<${href}>; rel="related"; type="text/plain"; title="Full content"`
|
|
158
|
+
);
|
|
159
|
+
break;
|
|
160
|
+
case "sitemap":
|
|
161
|
+
case "sitemap-md":
|
|
162
|
+
links.push(
|
|
163
|
+
`<${href}>; rel="sitemap"; type="${kind === "sitemap-md" ? "text/markdown" : "application/xml"}"`
|
|
164
|
+
), headers.set("x-publishos-sitemap", href);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (scope?.describedBy !== void 0) {
|
|
169
|
+
let href = /[\s<>"\\]/u.test(scope.describedBy) ? void 0 : publicRecoveryHref(scope.describedBy);
|
|
170
|
+
href && (links.push(`<${href}>; rel="describedby"; type="text/plain"`), headers.set("x-publishos-llms", href));
|
|
171
|
+
}
|
|
172
|
+
return links.length && headers.set("link", links.join(", ")), headers;
|
|
173
|
+
}
|
|
174
|
+
function createNotFoundTextResponse({
|
|
175
|
+
scope,
|
|
176
|
+
pathname,
|
|
177
|
+
method,
|
|
178
|
+
contentType = "text/markdown; charset=utf-8",
|
|
179
|
+
vary = !1
|
|
180
|
+
}) {
|
|
181
|
+
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;
|
|
182
|
+
if (resolvedScope && path) {
|
|
183
|
+
let explanation = requestExplanation({
|
|
184
|
+
pathname: path,
|
|
185
|
+
origin: scope?.origin
|
|
186
|
+
}), headingEnd = body.indexOf(`
|
|
187
|
+
|
|
188
|
+
`);
|
|
189
|
+
body = headingEnd === -1 ? `${body}
|
|
190
|
+
|
|
191
|
+
${explanation}
|
|
192
|
+
` : `${body.slice(0, headingEnd)}
|
|
193
|
+
|
|
194
|
+
${explanation}
|
|
195
|
+
|
|
196
|
+
${body.slice(headingEnd + 2)}`;
|
|
197
|
+
}
|
|
198
|
+
let headers = discoveryHeaders(resolvedScope);
|
|
199
|
+
return vary && headers.set("vary", "Accept, User-Agent"), createCachedTextResponse({
|
|
200
|
+
body,
|
|
201
|
+
cachePolicy: "short",
|
|
202
|
+
contentType,
|
|
203
|
+
headers,
|
|
204
|
+
method,
|
|
205
|
+
noindex: !0,
|
|
206
|
+
status: 404
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
createNotFoundTextResponse,
|
|
211
|
+
resolveNotFoundScope,
|
|
212
|
+
serializeNotFoundMarkdown
|
|
213
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Metadata } from 'next';
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
|
-
import { OgManifestLike } from '
|
|
5
|
-
import {
|
|
4
|
+
import { O as OgManifestLike } from '../../../route-metadata-og-image-BeKKFHg7.js';
|
|
5
|
+
import { ManifestLike, IndexPageProps } from '../../../types.js';
|
|
6
6
|
|
|
7
7
|
type IndexPageComponent = (props: IndexPageProps) => ReactElement | Promise<ReactElement>;
|
|
8
8
|
type GroupRouteConfig = {
|
|
@@ -20,6 +20,17 @@ var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// src/lib/runtime/metadata/canonical-url.ts
|
|
24
|
+
function canonicalUrl(manifest, path, group) {
|
|
25
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
26
|
+
if (!origin) return path;
|
|
27
|
+
try {
|
|
28
|
+
return new URL(path, `${origin}/`).toString();
|
|
29
|
+
} catch {
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
// src/lib/runtime/metadata/agent-metadata.ts
|
|
24
35
|
function normalizePath(path) {
|
|
25
36
|
let prefixed = path.startsWith("/") ? path : `/${path}`;
|
|
@@ -27,11 +38,13 @@ function normalizePath(path) {
|
|
|
27
38
|
}
|
|
28
39
|
function agentReadableAlternates({
|
|
29
40
|
canonicalPath,
|
|
41
|
+
group,
|
|
30
42
|
manifest,
|
|
31
43
|
markdownPath
|
|
32
44
|
}) {
|
|
45
|
+
let canonical = canonicalUrl(manifest, normalizePath(canonicalPath), group);
|
|
33
46
|
return {
|
|
34
|
-
...
|
|
47
|
+
...canonical.startsWith("http") ? { canonical } : {},
|
|
35
48
|
types: {
|
|
36
49
|
...markdownPath ? { "text/markdown": normalizePath(markdownPath) } : {},
|
|
37
50
|
"text/plain": "/llms.txt"
|
|
@@ -40,29 +53,22 @@ function agentReadableAlternates({
|
|
|
40
53
|
}
|
|
41
54
|
|
|
42
55
|
// src/lib/runtime/metadata/social-metadata.ts
|
|
43
|
-
function absoluteUrl({
|
|
44
|
-
path,
|
|
45
|
-
siteUrl
|
|
46
|
-
}) {
|
|
47
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
48
|
-
if (siteUrl)
|
|
49
|
-
return new URL(path, siteUrl).toString();
|
|
50
|
-
}
|
|
51
56
|
function createSocialMetadata({
|
|
52
57
|
canonicalPath,
|
|
53
58
|
description,
|
|
59
|
+
group,
|
|
54
60
|
manifest,
|
|
55
61
|
ogManifest,
|
|
56
62
|
title,
|
|
57
63
|
type = "website"
|
|
58
64
|
}) {
|
|
59
|
-
let key = ogManifest?.routes?.[canonicalPath],
|
|
65
|
+
let key = ogManifest?.routes?.[canonicalPath], entry = key ? ogManifest?.entries?.[key] : void 0, url = canonicalUrl(manifest, canonicalPath, group), hasOrigin = (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin, imageUrl = entry && (/^https?:\/\//i.test(entry.url) || hasOrigin) ? canonicalUrl(manifest, entry.url, group) : void 0;
|
|
60
66
|
return !entry || !imageUrl ? {
|
|
61
67
|
openGraph: {
|
|
62
68
|
description,
|
|
63
69
|
title,
|
|
64
70
|
type,
|
|
65
|
-
...url ? { url } : {}
|
|
71
|
+
...url.startsWith("http") ? { url } : {}
|
|
66
72
|
},
|
|
67
73
|
twitter: {
|
|
68
74
|
card: "summary",
|
|
@@ -83,7 +89,7 @@ function createSocialMetadata({
|
|
|
83
89
|
siteName: manifest.site.name,
|
|
84
90
|
title,
|
|
85
91
|
type,
|
|
86
|
-
...url ? { url } : {}
|
|
92
|
+
...url.startsWith("http") ? { url } : {}
|
|
87
93
|
},
|
|
88
94
|
twitter: {
|
|
89
95
|
card: "summary_large_image",
|
|
@@ -95,7 +101,7 @@ function createSocialMetadata({
|
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
// src/route-page-group.tsx
|
|
98
|
-
import { jsx } from "
|
|
104
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
99
105
|
var manifests = /* @__PURE__ */ new Map(), indexPages = /* @__PURE__ */ new Map();
|
|
100
106
|
async function CachedGroupPage({ group }) {
|
|
101
107
|
"use cache";
|
|
@@ -125,11 +131,13 @@ function createGroupMetadata({
|
|
|
125
131
|
description,
|
|
126
132
|
alternates: groupData ? agentReadableAlternates({
|
|
127
133
|
canonicalPath: groupData.path,
|
|
134
|
+
group,
|
|
128
135
|
manifest
|
|
129
136
|
}) : void 0,
|
|
130
137
|
...createSocialMetadata({
|
|
131
138
|
canonicalPath,
|
|
132
139
|
description,
|
|
140
|
+
group,
|
|
133
141
|
manifest,
|
|
134
142
|
ogManifest,
|
|
135
143
|
title
|
|
@@ -4,6 +4,32 @@ import { ReactElement, ReactNode } from 'react';
|
|
|
4
4
|
import { O as OgManifestLike } from '../../../route-metadata-og-image-BeKKFHg7.js';
|
|
5
5
|
import { PageProps, ManifestLike, ResolvedAttribution } from '../../../types.js';
|
|
6
6
|
|
|
7
|
+
type MarkdownRouteArtifact = {
|
|
8
|
+
body: string;
|
|
9
|
+
bodyHash?: string;
|
|
10
|
+
byteSize?: number;
|
|
11
|
+
htmlPath: string;
|
|
12
|
+
markdownPath: string;
|
|
13
|
+
sourceHash?: string;
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
type MarkdownRouteArtifactIndexEntry = Omit<MarkdownRouteArtifact, "body"> & {
|
|
17
|
+
shardId: string;
|
|
18
|
+
};
|
|
19
|
+
type MarkdownRouteArtifactIndex = Record<string, MarkdownRouteArtifactIndexEntry>;
|
|
20
|
+
type MarkdownRouteArtifactShardMetadata = {
|
|
21
|
+
byteSize: number;
|
|
22
|
+
contentHash: string;
|
|
23
|
+
id: string;
|
|
24
|
+
modulePath: string;
|
|
25
|
+
pageCount: number;
|
|
26
|
+
};
|
|
27
|
+
type MarkdownRouteArtifactManifest = {
|
|
28
|
+
byHtmlPath: Record<string, string>;
|
|
29
|
+
byMarkdownPath: MarkdownRouteArtifactIndex;
|
|
30
|
+
shards: MarkdownRouteArtifactShardMetadata[];
|
|
31
|
+
};
|
|
32
|
+
|
|
7
33
|
type LeafComponent = (props: PageProps) => ReactElement | Promise<ReactElement>;
|
|
8
34
|
type PoweredByFooterComponent = (props: {
|
|
9
35
|
attribution: ResolvedAttribution;
|
|
@@ -11,6 +37,7 @@ type PoweredByFooterComponent = (props: {
|
|
|
11
37
|
type LeafRouteConfig = {
|
|
12
38
|
group: string;
|
|
13
39
|
manifest: ManifestLike;
|
|
40
|
+
markdownArtifactManifest?: Pick<MarkdownRouteArtifactManifest, "byMarkdownPath">;
|
|
14
41
|
ogManifest?: OgManifestLike;
|
|
15
42
|
Leaf: LeafComponent;
|
|
16
43
|
PoweredByFooter?: PoweredByFooterComponent;
|
|
@@ -27,7 +54,7 @@ declare function appendPoweredByFooter({ footer, node, }: {
|
|
|
27
54
|
node: ReactNode;
|
|
28
55
|
placed: boolean;
|
|
29
56
|
};
|
|
30
|
-
declare function createLeafPage({ group, manifest, Leaf, PoweredByFooter, }: LeafRouteConfig): ({ params }: PageRouteProps) => Promise<react_jsx_runtime.JSX.Element>;
|
|
57
|
+
declare function createLeafPage({ group, manifest, markdownArtifactManifest, Leaf, PoweredByFooter, }: LeafRouteConfig): ({ params }: PageRouteProps) => Promise<react_jsx_runtime.JSX.Element>;
|
|
31
58
|
declare function createLeafMetadata({ group, manifest, ogManifest, }: LeafRouteConfig): ({ params, }: PageRouteProps) => Promise<Metadata>;
|
|
32
59
|
declare function createLeafStaticParams({ group, manifest }: LeafRouteConfig): () => {
|
|
33
60
|
slug: string[];
|
|
@@ -29,6 +29,17 @@ var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
// src/lib/runtime/metadata/canonical-url.ts
|
|
33
|
+
function canonicalUrl(manifest, path, group) {
|
|
34
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
35
|
+
if (!origin) return path;
|
|
36
|
+
try {
|
|
37
|
+
return new URL(path, `${origin}/`).toString();
|
|
38
|
+
} catch {
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
// src/lib/runtime/metadata/agent-metadata.ts
|
|
33
44
|
function normalizePath(path) {
|
|
34
45
|
let prefixed = path.startsWith("/") ? path : `/${path}`;
|
|
@@ -40,11 +51,13 @@ function markdownPathForHtmlPath(path) {
|
|
|
40
51
|
}
|
|
41
52
|
function agentReadableAlternates({
|
|
42
53
|
canonicalPath,
|
|
54
|
+
group,
|
|
43
55
|
manifest,
|
|
44
56
|
markdownPath
|
|
45
57
|
}) {
|
|
58
|
+
let canonical = canonicalUrl(manifest, normalizePath(canonicalPath), group);
|
|
46
59
|
return {
|
|
47
|
-
...
|
|
60
|
+
...canonical.startsWith("http") ? { canonical } : {},
|
|
48
61
|
types: {
|
|
49
62
|
...markdownPath ? { "text/markdown": normalizePath(markdownPath) } : {},
|
|
50
63
|
"text/plain": "/llms.txt"
|
|
@@ -53,29 +66,22 @@ function agentReadableAlternates({
|
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
// src/lib/runtime/metadata/social-metadata.ts
|
|
56
|
-
function absoluteUrl({
|
|
57
|
-
path,
|
|
58
|
-
siteUrl
|
|
59
|
-
}) {
|
|
60
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
61
|
-
if (siteUrl)
|
|
62
|
-
return new URL(path, siteUrl).toString();
|
|
63
|
-
}
|
|
64
69
|
function createSocialMetadata({
|
|
65
70
|
canonicalPath,
|
|
66
71
|
description,
|
|
72
|
+
group,
|
|
67
73
|
manifest,
|
|
68
74
|
ogManifest,
|
|
69
75
|
title,
|
|
70
76
|
type = "website"
|
|
71
77
|
}) {
|
|
72
|
-
let key = ogManifest?.routes?.[canonicalPath],
|
|
78
|
+
let key = ogManifest?.routes?.[canonicalPath], entry = key ? ogManifest?.entries?.[key] : void 0, url = canonicalUrl(manifest, canonicalPath, group), hasOrigin = (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin, imageUrl = entry && (/^https?:\/\//i.test(entry.url) || hasOrigin) ? canonicalUrl(manifest, entry.url, group) : void 0;
|
|
73
79
|
return !entry || !imageUrl ? {
|
|
74
80
|
openGraph: {
|
|
75
81
|
description,
|
|
76
82
|
title,
|
|
77
83
|
type,
|
|
78
|
-
...url ? { url } : {}
|
|
84
|
+
...url.startsWith("http") ? { url } : {}
|
|
79
85
|
},
|
|
80
86
|
twitter: {
|
|
81
87
|
card: "summary",
|
|
@@ -96,7 +102,7 @@ function createSocialMetadata({
|
|
|
96
102
|
siteName: manifest.site.name,
|
|
97
103
|
title,
|
|
98
104
|
type,
|
|
99
|
-
...url ? { url } : {}
|
|
105
|
+
...url.startsWith("http") ? { url } : {}
|
|
100
106
|
},
|
|
101
107
|
twitter: {
|
|
102
108
|
card: "summary_large_image",
|
|
@@ -108,8 +114,8 @@ function createSocialMetadata({
|
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
// src/route-page-leaf.tsx
|
|
111
|
-
import { jsx, jsxs } from "
|
|
112
|
-
var manifests = /* @__PURE__ */ new Map(), leaves = /* @__PURE__ */ new Map(), poweredByFooters = /* @__PURE__ */ new Map();
|
|
117
|
+
import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
|
|
118
|
+
var manifests = /* @__PURE__ */ new Map(), markdownArtifactIndexes = /* @__PURE__ */ new Map(), leaves = /* @__PURE__ */ new Map(), poweredByFooters = /* @__PURE__ */ new Map();
|
|
113
119
|
function hasClassName(value, className) {
|
|
114
120
|
return typeof value == "string" && value.split(/\s+/).includes(className);
|
|
115
121
|
}
|
|
@@ -198,7 +204,7 @@ async function CachedLeafPage({
|
|
|
198
204
|
(!manifest || !Leaf) && notFound(), cacheTag(tags.manifest(manifest.contentHash)), log.debug("[cache]", `${group}/${slug.join("/")}`);
|
|
199
205
|
let resolved = resolveLeaf(manifest, group, slug);
|
|
200
206
|
resolved || notFound();
|
|
201
|
-
let attribution = manifest.attribution?.[group] ?? { enabled: !1 }, leaf = await Leaf(resolved), footer = attribution.enabled && PoweredByFooter ? /* @__PURE__ */ jsx(PoweredByFooter, { attribution }) : null, placed = footer ? appendPoweredByFooter({ footer, node: leaf }) : { node: leaf, placed: !0 };
|
|
207
|
+
let attribution = manifest.attribution?.[group] ?? { enabled: !1 }, markdownRevision = markdownArtifactIndexes.get(group)?.[markdownPathForHtmlPath(resolved.page.path)]?.bodyHash, leaf = await Leaf({ ...resolved, markdownRevision }), footer = attribution.enabled && PoweredByFooter ? /* @__PURE__ */ jsx(PoweredByFooter, { attribution }) : null, placed = footer ? appendPoweredByFooter({ footer, node: leaf }) : { node: leaf, placed: !0 };
|
|
202
208
|
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-full min-w-0 flex-1 flex-col", children: [
|
|
203
209
|
placed.node,
|
|
204
210
|
footer && !placed.placed ? footer : null
|
|
@@ -207,10 +213,11 @@ async function CachedLeafPage({
|
|
|
207
213
|
function createLeafPage({
|
|
208
214
|
group,
|
|
209
215
|
manifest,
|
|
216
|
+
markdownArtifactManifest,
|
|
210
217
|
Leaf,
|
|
211
218
|
PoweredByFooter
|
|
212
219
|
}) {
|
|
213
|
-
return manifests.set(group, manifest), leaves.set(group, Leaf), PoweredByFooter ? poweredByFooters.set(group, PoweredByFooter) : poweredByFooters.delete(group), async function({ params }) {
|
|
220
|
+
return manifests.set(group, manifest), markdownArtifactManifest ? markdownArtifactIndexes.set(group, markdownArtifactManifest.byMarkdownPath) : markdownArtifactIndexes.delete(group), leaves.set(group, Leaf), PoweredByFooter ? poweredByFooters.set(group, PoweredByFooter) : poweredByFooters.delete(group), async function({ params }) {
|
|
214
221
|
let { slug = [] } = await params;
|
|
215
222
|
return log.debug("[render]", `${group}/${slug.join("/")}`), /* @__PURE__ */ jsx(CachedLeafPage, { group, slug });
|
|
216
223
|
};
|
|
@@ -231,12 +238,14 @@ function createLeafMetadata({
|
|
|
231
238
|
description: resolved.page.description,
|
|
232
239
|
alternates: agentReadableAlternates({
|
|
233
240
|
canonicalPath: resolved.page.path,
|
|
241
|
+
group,
|
|
234
242
|
manifest,
|
|
235
243
|
markdownPath: markdownPathForHtmlPath(resolved.page.path)
|
|
236
244
|
}),
|
|
237
245
|
...createSocialMetadata({
|
|
238
246
|
canonicalPath: resolved.page.path,
|
|
239
247
|
description: resolved.page.description,
|
|
248
|
+
group,
|
|
240
249
|
manifest,
|
|
241
250
|
ogManifest,
|
|
242
251
|
title: resolved.page.title,
|
|
@@ -18,6 +18,17 @@ var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// src/lib/runtime/metadata/canonical-url.ts
|
|
22
|
+
function canonicalUrl(manifest, path, group) {
|
|
23
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
24
|
+
if (!origin) return path;
|
|
25
|
+
try {
|
|
26
|
+
return new URL(path, `${origin}/`).toString();
|
|
27
|
+
} catch {
|
|
28
|
+
return path;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
// src/lib/runtime/metadata/agent-metadata.ts
|
|
22
33
|
function normalizePath(path) {
|
|
23
34
|
let prefixed = path.startsWith("/") ? path : `/${path}`;
|
|
@@ -25,11 +36,13 @@ function normalizePath(path) {
|
|
|
25
36
|
}
|
|
26
37
|
function agentReadableAlternates({
|
|
27
38
|
canonicalPath,
|
|
39
|
+
group,
|
|
28
40
|
manifest,
|
|
29
41
|
markdownPath
|
|
30
42
|
}) {
|
|
43
|
+
let canonical = canonicalUrl(manifest, normalizePath(canonicalPath), group);
|
|
31
44
|
return {
|
|
32
|
-
...
|
|
45
|
+
...canonical.startsWith("http") ? { canonical } : {},
|
|
33
46
|
types: {
|
|
34
47
|
...markdownPath ? { "text/markdown": normalizePath(markdownPath) } : {},
|
|
35
48
|
"text/plain": "/llms.txt"
|
|
@@ -38,29 +51,22 @@ function agentReadableAlternates({
|
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
// src/lib/runtime/metadata/social-metadata.ts
|
|
41
|
-
function absoluteUrl({
|
|
42
|
-
path,
|
|
43
|
-
siteUrl
|
|
44
|
-
}) {
|
|
45
|
-
if (/^https?:\/\//i.test(path)) return path;
|
|
46
|
-
if (siteUrl)
|
|
47
|
-
return new URL(path, siteUrl).toString();
|
|
48
|
-
}
|
|
49
54
|
function createSocialMetadata({
|
|
50
55
|
canonicalPath,
|
|
51
56
|
description,
|
|
57
|
+
group,
|
|
52
58
|
manifest,
|
|
53
59
|
ogManifest,
|
|
54
60
|
title,
|
|
55
61
|
type = "website"
|
|
56
62
|
}) {
|
|
57
|
-
let key = ogManifest?.routes?.[canonicalPath],
|
|
63
|
+
let key = ogManifest?.routes?.[canonicalPath], entry = key ? ogManifest?.entries?.[key] : void 0, url = canonicalUrl(manifest, canonicalPath, group), hasOrigin = (group ? manifest.groups[group]?.origin : void 0) ?? manifest.site.origin, imageUrl = entry && (/^https?:\/\//i.test(entry.url) || hasOrigin) ? canonicalUrl(manifest, entry.url, group) : void 0;
|
|
58
64
|
return !entry || !imageUrl ? {
|
|
59
65
|
openGraph: {
|
|
60
66
|
description,
|
|
61
67
|
title,
|
|
62
68
|
type,
|
|
63
|
-
...url ? { url } : {}
|
|
69
|
+
...url.startsWith("http") ? { url } : {}
|
|
64
70
|
},
|
|
65
71
|
twitter: {
|
|
66
72
|
card: "summary",
|
|
@@ -81,7 +87,7 @@ function createSocialMetadata({
|
|
|
81
87
|
siteName: manifest.site.name,
|
|
82
88
|
title,
|
|
83
89
|
type,
|
|
84
|
-
...url ? { url } : {}
|
|
90
|
+
...url.startsWith("http") ? { url } : {}
|
|
85
91
|
},
|
|
86
92
|
twitter: {
|
|
87
93
|
card: "summary_large_image",
|
|
@@ -93,7 +99,7 @@ function createSocialMetadata({
|
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
// src/route-page-root.tsx
|
|
96
|
-
import { jsx } from "
|
|
102
|
+
import { jsx } from "@publish.os/nextjs/jsx-runtime";
|
|
97
103
|
var rootManifest, rootPage;
|
|
98
104
|
async function CachedRootPage() {
|
|
99
105
|
"use cache";
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
// src/lib/runtime/metadata/canonical-url.ts
|
|
2
|
+
function canonicalUrl(manifest, path, group) {
|
|
3
|
+
let origin = (group && manifest.groups[group]?.origin) ?? manifest.site.origin;
|
|
4
|
+
if (!origin) return path;
|
|
5
|
+
try {
|
|
6
|
+
return new URL(path, `${origin}/`).toString();
|
|
7
|
+
} catch {
|
|
8
|
+
return path;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function navigationUrl(manifest, path, group) {
|
|
12
|
+
let origin = manifest.groups[group]?.origin ?? manifest.site.origin;
|
|
13
|
+
return !origin || origin === manifest.site.origin ? path : canonicalUrl(manifest, path, group);
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
// src/manifest-resolver.ts
|
|
2
17
|
function findNodeInTree(nodes, id) {
|
|
3
18
|
for (let node of nodes) {
|
|
@@ -12,12 +27,13 @@ function findNodeInTree(nodes, id) {
|
|
|
12
27
|
}
|
|
13
28
|
return null;
|
|
14
29
|
}
|
|
15
|
-
function pageNode(page) {
|
|
30
|
+
function pageNode(manifest, page) {
|
|
16
31
|
return {
|
|
17
32
|
type: "page",
|
|
18
33
|
fileID: page.fileID,
|
|
19
34
|
title: page.title,
|
|
20
35
|
path: page.path,
|
|
36
|
+
href: navigationUrl(manifest, page.path, page.group),
|
|
21
37
|
group: page.group,
|
|
22
38
|
description: page.description,
|
|
23
39
|
status: page.status,
|
|
@@ -28,12 +44,13 @@ function pageNode(page) {
|
|
|
28
44
|
meta: page.meta
|
|
29
45
|
};
|
|
30
46
|
}
|
|
31
|
-
function groupNode(group) {
|
|
47
|
+
function groupNode(manifest, group) {
|
|
32
48
|
return {
|
|
33
49
|
type: "section",
|
|
34
50
|
id: group.key,
|
|
35
51
|
title: group.title,
|
|
36
52
|
path: group.path,
|
|
53
|
+
href: navigationUrl(manifest, group.path, group.key),
|
|
37
54
|
group: group.key,
|
|
38
55
|
children: group.tree
|
|
39
56
|
};
|
|
@@ -43,9 +60,12 @@ function resolveLeaf(manifest, group, slug) {
|
|
|
43
60
|
if (!page) return null;
|
|
44
61
|
let groupData = manifest.groups[group];
|
|
45
62
|
return groupData ? {
|
|
46
|
-
site:
|
|
63
|
+
site: {
|
|
64
|
+
...manifest.site,
|
|
65
|
+
origin: groupData.origin ?? manifest.site.origin
|
|
66
|
+
},
|
|
47
67
|
tree: groupData.tree,
|
|
48
|
-
node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(page),
|
|
68
|
+
node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(manifest, page),
|
|
49
69
|
page,
|
|
50
70
|
currentPath: page.path,
|
|
51
71
|
group
|
|
@@ -54,9 +74,12 @@ function resolveLeaf(manifest, group, slug) {
|
|
|
54
74
|
function resolveGroup(manifest, group) {
|
|
55
75
|
let groupData = manifest.groups[group];
|
|
56
76
|
return groupData ? {
|
|
57
|
-
site:
|
|
77
|
+
site: {
|
|
78
|
+
...manifest.site,
|
|
79
|
+
origin: groupData.origin ?? manifest.site.origin
|
|
80
|
+
},
|
|
58
81
|
tree: groupData.tree,
|
|
59
|
-
node: groupNode(groupData),
|
|
82
|
+
node: groupNode(manifest, groupData),
|
|
60
83
|
currentPath: groupData.path,
|
|
61
84
|
group
|
|
62
85
|
} : null;
|