@publish.os/nextjs 0.0.1-alpha.6 → 0.0.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/compiler-assets/nextjs/defaults/app/globals.css +6 -0
- package/compiler-assets/nextjs/defaults/group/layout.tsx +23 -0
- package/compiler-assets/nextjs/defaults/group/leaf.tsx +48 -0
- package/compiler-assets/nextjs/defaults/group/page.tsx +50 -0
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +45 -0
- package/compiler-assets/nextjs/defaults/project/postcss.config.mjs +5 -0
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +41 -0
- package/compiler-assets/nextjs/defaults/root/css/animation.css +90 -0
- package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/drawer.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/menu.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +25 -0
- package/compiler-assets/nextjs/defaults/root/css/components/popover.css +17 -0
- package/compiler-assets/nextjs/defaults/root/css/components/select.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/toast.css +19 -0
- package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +15 -0
- package/compiler-assets/nextjs/defaults/root/css/layout.css +22 -0
- package/compiler-assets/nextjs/defaults/root/css/media.css +81 -0
- package/compiler-assets/nextjs/defaults/root/css/radius.css +49 -0
- package/compiler-assets/nextjs/defaults/root/css/scrollbar.css +43 -0
- package/compiler-assets/nextjs/defaults/root/css/shadow.css +145 -0
- package/compiler-assets/nextjs/defaults/root/css/typography.css +607 -0
- package/compiler-assets/nextjs/defaults/root/css/zindex.css +39 -0
- package/compiler-assets/nextjs/defaults/root/globals.css +191 -0
- package/compiler-assets/nextjs/defaults/root/layout.tsx +19 -0
- package/compiler-assets/nextjs/defaults/root/page.tsx +61 -0
- package/compiler-assets/nextjs/defaults/root/theme.css +50 -0
- package/compiler-assets/nextjs/defaults/source/_internal/logger.ts +21 -0
- package/compiler-assets/nextjs/shims/generated-group-layout.tsx +19 -0
- package/compiler-assets/nextjs/shims/generated-group-page.tsx +18 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +21 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +134 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +29 -0
- package/compiler-assets/nextjs/shims/og-image-route.ts +18 -0
- package/compiler-assets/nextjs/shims/powered-by-footer.tsx +40 -0
- package/compiler-assets/nextjs/shims/providers.tsx +13 -0
- package/compiler-assets/nextjs/shims/proxy.ts +317 -0
- package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +77 -0
- package/compiler-assets/nextjs/shims/root-page.tsx +13 -0
- package/compiler-assets/nextjs/shims/theme-defaults.css +177 -0
- package/dist/button-CFdx-ohV.d.ts +20 -0
- package/dist/cache/tags.js +6 -14
- package/dist/compiler.d.ts +100 -0
- package/dist/compiler.js +13379 -0
- package/dist/config/createNextConfig.d.ts +2 -1
- package/dist/config/createNextConfig.js +16 -12
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +303 -15
- package/dist/index.js +30 -1198
- package/dist/kernel/components/blocks/AgentActions.d.ts +9 -3
- package/dist/kernel/components/blocks/AgentActions.js +114 -200
- package/dist/kernel/components/blocks/animated-icon-swap.js +4 -25
- package/dist/kernel/components/blocks/color-palette.js +88 -169
- package/dist/kernel/components/blocks/design-system-preview.d.ts +38 -6
- package/dist/kernel/components/blocks/design-system-preview.js +44 -52
- package/dist/kernel/components/blocks/link-playground.js +23 -71
- package/dist/kernel/components/blocks/logo-block.js +18 -47
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +28 -42
- package/dist/kernel/components/blocks/navbar.d.ts +1 -1
- package/dist/kernel/components/blocks/navbar.js +14 -41
- package/dist/kernel/components/blocks/navigation-progress-playground.js +56 -149
- package/dist/kernel/components/blocks/navigation-progress.js +53 -157
- package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
- package/dist/kernel/components/blocks/next-prev.js +16 -42
- package/dist/kernel/components/blocks/page-list.d.ts +1 -1
- package/dist/kernel/components/blocks/page-list.js +11 -16
- package/dist/kernel/components/blocks/search.d.ts +13 -2
- package/dist/kernel/components/blocks/search.js +116 -247
- package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
- package/dist/kernel/components/blocks/sidebar-node.js +56 -95
- package/dist/kernel/components/blocks/sidebar.d.ts +5 -23
- package/dist/kernel/components/blocks/sidebar.js +35 -103
- package/dist/kernel/components/blocks/theme-toggle.d.ts +7 -3
- package/dist/kernel/components/blocks/theme-toggle.js +2 -2
- package/dist/kernel/components/blocks/toc.js +42 -178
- package/dist/kernel/components/mdx/components/blockquote.js +3 -24
- package/dist/kernel/components/mdx/components/callout.d.ts +1 -1
- package/dist/kernel/components/mdx/components/callout.js +15 -47
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/figure-caption.js +6 -24
- package/dist/kernel/components/mdx/components/figure.js +9 -36
- package/dist/kernel/components/mdx/components/footnotes.js +3 -24
- package/dist/kernel/components/mdx/components/heading-copy-link.js +13 -37
- package/dist/kernel/components/mdx/components/heading.d.ts +8 -3
- package/dist/kernel/components/mdx/components/heading.js +32 -116
- package/dist/kernel/components/mdx/components/hr.d.ts +5 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +2 -3
- package/dist/kernel/components/mdx/components/image.js +22 -62
- package/dist/kernel/components/mdx/components/inline-code.js +3 -24
- package/dist/kernel/components/mdx/components/kbd.d.ts +9 -4
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +1 -2
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +13 -41
- package/dist/kernel/components/mdx/components/pre.js +3 -24
- package/dist/kernel/components/mdx/components/strikethrough.js +6 -24
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +6 -28
- package/dist/kernel/components/mdx/components/video-player.js +53 -88
- package/dist/kernel/components/mdx/components/video.js +27 -75
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +12 -15
- package/dist/kernel/components/mdx/error-fallback.js +4 -4
- package/dist/kernel/components/mdx/mdx.d.ts +68 -11
- package/dist/kernel/components/mdx/mdx.js +29 -29
- package/dist/kernel/components/mdx/rehype-heading-ids.js +11 -67
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/ui/accordion.js +3 -26
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +23 -7
- package/dist/kernel/components/ui/breadcrumb-trail.js +32 -80
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +20 -54
- package/dist/kernel/components/ui/button-group.d.ts +4 -3
- package/dist/kernel/components/ui/button-group.js +7 -30
- package/dist/kernel/components/ui/button.js +13 -36
- package/dist/kernel/components/ui/card.d.ts +2 -2
- package/dist/kernel/components/ui/card.js +2 -23
- package/dist/kernel/components/ui/dialog.d.ts +9 -9
- package/dist/kernel/components/ui/dialog.js +15 -33
- package/dist/kernel/components/ui/drawer.d.ts +10 -10
- package/dist/kernel/components/ui/drawer.js +15 -33
- package/dist/kernel/components/ui/input.js +6 -30
- package/dist/kernel/components/ui/kbd.js +10 -31
- package/dist/kernel/components/ui/link.d.ts +1 -1
- package/dist/kernel/components/ui/link.js +53 -104
- package/dist/kernel/components/ui/menu.d.ts +21 -21
- package/dist/kernel/components/ui/menu.js +10 -32
- package/dist/kernel/components/ui/meta-key.d.ts +9 -4
- package/dist/kernel/components/ui/meta-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.d.ts +14 -14
- package/dist/kernel/components/ui/navigation-menu.js +9 -30
- package/dist/kernel/components/ui/popover.d.ts +10 -10
- package/dist/kernel/components/ui/popover.js +19 -34
- package/dist/kernel/components/ui/progress.js +2 -25
- package/dist/kernel/components/ui/scroll-area.js +39 -118
- package/dist/kernel/components/ui/select.d.ts +15 -15
- package/dist/kernel/components/ui/select.js +19 -35
- package/dist/kernel/components/ui/separator.js +2 -25
- package/dist/kernel/components/ui/table.js +2 -23
- package/dist/kernel/components/ui/tabs.js +39 -99
- package/dist/kernel/components/ui/tag.d.ts +2 -2
- package/dist/kernel/components/ui/tag.js +4 -25
- package/dist/kernel/components/ui/text.d.ts +2 -2
- package/dist/kernel/components/ui/text.js +3 -25
- package/dist/kernel/components/ui/theme-toggle.d.ts +18 -4
- package/dist/kernel/components/ui/theme-toggle.js +18 -44
- package/dist/kernel/components/ui/toast.d.ts +10 -10
- package/dist/kernel/components/ui/toast.js +13 -35
- package/dist/kernel/components/ui/tooltip.d.ts +8 -8
- package/dist/kernel/components/ui/tooltip.js +8 -29
- package/dist/kernel/defaults.registry.d.ts +1 -1
- package/dist/kernel/defaults.registry.js +2 -2
- package/dist/kernel/framework-icons.d.ts +1 -0
- package/dist/kernel/framework-icons.js +39 -0
- package/dist/kernel/routes/agent/markdown.js +36 -65
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +20 -109
- package/dist/kernel/routes/metadata/feed.d.ts +1 -2
- package/dist/kernel/routes/metadata/feed.js +46 -127
- package/dist/kernel/routes/metadata/llms.d.ts +1 -2
- package/dist/kernel/routes/metadata/llms.js +40 -120
- package/dist/kernel/routes/metadata/og-image.d.ts +10 -0
- package/dist/kernel/routes/metadata/og-image.js +264 -198
- package/dist/kernel/routes/metadata/robots.d.ts +1 -2
- package/dist/kernel/routes/metadata/robots.js +21 -90
- package/dist/kernel/routes/metadata/sitemap.d.ts +1 -2
- package/dist/kernel/routes/metadata/sitemap.js +36 -102
- package/dist/kernel/routes/pages/group.d.ts +1 -1
- package/dist/kernel/routes/pages/group.js +42 -137
- package/dist/kernel/routes/pages/leaf.d.ts +1 -1
- package/dist/kernel/routes/pages/leaf.js +74 -213
- package/dist/kernel/routes/pages/root.d.ts +1 -1
- package/dist/kernel/routes/pages/root.js +37 -108
- package/dist/keyboard-shortcuts.js +69 -141
- package/dist/link-CYaCRDb6.d.ts +35 -0
- package/dist/resolvers/manifest-resolver.d.ts +3 -3
- package/dist/resolvers/manifest-resolver.js +15 -21
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.d.ts +81 -4
- package/dist/search.js +124 -195
- package/dist/sidebar-types-Bgchdfd6.d.ts +25 -0
- package/dist/theme-scope.d.ts +15 -0
- package/dist/theme-scope.js +23 -0
- package/dist/types-B_b3C0U6.d.ts +63 -0
- package/dist/types-CIwwieNw.d.ts +127 -0
- package/dist/types-DHBm7-j6.d.ts +57 -0
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +0 -1
- package/dist/types.js +1 -1
- package/dist/utils/cn.d.ts +5 -9
- package/dist/utils/cn.js +13 -7
- package/dist/utils/heading-ids.js +20 -47
- package/dist/utils/pretty-date.js +7 -13
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.png +0 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +54 -0
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +31 -0
- package/init/seed/minimal/publish.os/docs/content/theme.mdx +64 -0
- package/init/seed/minimal/publish.os/publish.os.config.json +21 -0
- package/init/seed/minimal/publish.os/theme.css +47 -0
- package/init/seed/minimal/seed.json +13 -0
- package/package.json +469 -35
- package/release/{package.json → app/lucide/package.json} +11 -5
- package/release/app/lucide/pnpm-lock.yaml.template +2905 -0
- package/release/app/lucide/pnpm-workspace.yaml +11 -0
- package/release/app/phosphor/package.json +30 -0
- package/release/app/phosphor/pnpm-lock.yaml.template +2908 -0
- package/release/app/phosphor/pnpm-workspace.yaml +11 -0
- package/release/app/tabler/package.json +30 -0
- package/release/app/tabler/pnpm-lock.yaml.template +2911 -0
- package/release/app/tabler/pnpm-workspace.yaml +11 -0
- package/release/compiler/package.json +20 -0
- package/release/compiler/pnpm-lock.yaml.template +2432 -0
- package/release/compiler/pnpm-workspace.yaml +11 -0
- package/release/release.json +29 -5
- package/release/runtime-pnpm-lock.yaml +0 -1316
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/route-page-leaf.tsx
|
|
2
|
+
import { tags } from "@publish.os/nextjs/cache/tags";
|
|
2
3
|
import { MDX } from "@publish.os/nextjs/mdx";
|
|
4
|
+
import {
|
|
5
|
+
listStaticParams,
|
|
6
|
+
resolveLeaf
|
|
7
|
+
} from "@publish.os/nextjs/resolvers/manifest-resolver";
|
|
3
8
|
import { cacheLife, cacheTag } from "next/cache";
|
|
4
9
|
import { notFound } from "next/navigation";
|
|
5
10
|
import {
|
|
@@ -8,64 +13,10 @@ import {
|
|
|
8
13
|
isValidElement
|
|
9
14
|
} from "react";
|
|
10
15
|
|
|
11
|
-
// src/
|
|
12
|
-
|
|
13
|
-
var MAX_TAG_LEN = 256;
|
|
14
|
-
var MAX_SEGMENT_LEN = 80;
|
|
15
|
-
var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
|
|
16
|
-
function sha256(value) {
|
|
17
|
-
return createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
18
|
-
}
|
|
19
|
-
function safeSegment(value) {
|
|
20
|
-
const raw = value.trim().toLowerCase() || "root";
|
|
21
|
-
const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
22
|
-
const segment = normalized || "root";
|
|
23
|
-
if (segment.length <= MAX_SEGMENT_LEN) return segment;
|
|
24
|
-
return `${segment.slice(0, 48)}.${sha256(segment)}`;
|
|
25
|
-
}
|
|
26
|
-
function assertTag(tag) {
|
|
27
|
-
if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
|
|
28
|
-
return `tag:${sha256(tag)}`;
|
|
29
|
-
}
|
|
30
|
-
return tag;
|
|
31
|
-
}
|
|
32
|
-
var tags = {
|
|
33
|
-
site() {
|
|
34
|
-
return "site";
|
|
35
|
-
},
|
|
36
|
-
pages() {
|
|
37
|
-
return "pages";
|
|
38
|
-
},
|
|
39
|
-
group(group) {
|
|
40
|
-
return assertTag(`group:${safeSegment(group)}`);
|
|
41
|
-
},
|
|
42
|
-
page(group, slug) {
|
|
43
|
-
const path = Array.isArray(slug) ? slug.join("/") : slug;
|
|
44
|
-
return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
|
|
45
|
-
},
|
|
46
|
-
manifest(contentHash) {
|
|
47
|
-
return assertTag(`manifest:${safeSegment(contentHash)}`);
|
|
48
|
-
},
|
|
49
|
-
sitemap() {
|
|
50
|
-
return "sitemap";
|
|
51
|
-
},
|
|
52
|
-
robots() {
|
|
53
|
-
return "robots";
|
|
54
|
-
},
|
|
55
|
-
llms(scope = "root") {
|
|
56
|
-
return assertTag(`llms:${safeSegment(scope)}`);
|
|
57
|
-
},
|
|
58
|
-
feed(format, scope = "site") {
|
|
59
|
-
return assertTag(`feed:${safeSegment(format)}:${safeSegment(scope)}`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// src/internal/utils/logger.ts
|
|
64
|
-
var isDev = process.env.NODE_ENV !== "production";
|
|
65
|
-
var isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1";
|
|
66
|
-
var log = {
|
|
16
|
+
// src/lib/runtime/logging/logger.ts
|
|
17
|
+
var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1", log = {
|
|
67
18
|
debug(...args) {
|
|
68
|
-
|
|
19
|
+
isDev && isDebugEnabled && console.debug("[publish.os:debug]", ...args);
|
|
69
20
|
},
|
|
70
21
|
info(...args) {
|
|
71
22
|
console.log("[publish.os]", ...args);
|
|
@@ -78,68 +29,14 @@ var log = {
|
|
|
78
29
|
}
|
|
79
30
|
};
|
|
80
31
|
|
|
81
|
-
// src/
|
|
82
|
-
function findNodeInTree(nodes, id) {
|
|
83
|
-
for (const node of nodes) {
|
|
84
|
-
if (node.type === "page") {
|
|
85
|
-
if (node.fileID === id) return node;
|
|
86
|
-
} else if (node.id === id) {
|
|
87
|
-
return node;
|
|
88
|
-
}
|
|
89
|
-
if (node.type === "section" || node.type === "folder") {
|
|
90
|
-
const found = findNodeInTree(node.children, id);
|
|
91
|
-
if (found) return found;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
function pageNode(page) {
|
|
97
|
-
return {
|
|
98
|
-
type: "page",
|
|
99
|
-
fileID: page.fileID,
|
|
100
|
-
title: page.title,
|
|
101
|
-
path: page.path,
|
|
102
|
-
group: page.group,
|
|
103
|
-
description: page.description,
|
|
104
|
-
status: page.status,
|
|
105
|
-
publishedAt: page.publishedAt,
|
|
106
|
-
updatedAt: page.updatedAt,
|
|
107
|
-
authors: page.authors,
|
|
108
|
-
tags: page.tags,
|
|
109
|
-
meta: page.meta
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function resolveLeaf(manifest, group, slug) {
|
|
113
|
-
const slugPath = Array.isArray(slug) ? slug.join("/") : slug;
|
|
114
|
-
const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
|
|
115
|
-
if (!page) return null;
|
|
116
|
-
const groupData = manifest.groups[group];
|
|
117
|
-
if (!groupData) return null;
|
|
118
|
-
return {
|
|
119
|
-
site: manifest.site,
|
|
120
|
-
tree: groupData.tree,
|
|
121
|
-
node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(page),
|
|
122
|
-
page,
|
|
123
|
-
currentPath: page.path,
|
|
124
|
-
group
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function listStaticParams(manifest, group) {
|
|
128
|
-
const groupData = manifest.groups[group];
|
|
129
|
-
if (!groupData) return [];
|
|
130
|
-
return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/kernel/routes/pages/agent-metadata.ts
|
|
32
|
+
// src/lib/runtime/metadata/agent-metadata.ts
|
|
134
33
|
function normalizePath(path) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return prefixed.replace(/\/+$/, "");
|
|
34
|
+
let prefixed = path.startsWith("/") ? path : `/${path}`;
|
|
35
|
+
return prefixed === "/" ? prefixed : prefixed.replace(/\/+$/, "");
|
|
138
36
|
}
|
|
139
37
|
function markdownPathForHtmlPath(path) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return `${normalized}.md`;
|
|
38
|
+
let normalized = normalizePath(path);
|
|
39
|
+
return normalized === "/" ? "/index.md" : `${normalized}.md`;
|
|
143
40
|
}
|
|
144
41
|
function agentReadableAlternates({
|
|
145
42
|
canonicalPath,
|
|
@@ -155,15 +52,14 @@ function agentReadableAlternates({
|
|
|
155
52
|
};
|
|
156
53
|
}
|
|
157
54
|
|
|
158
|
-
// src/
|
|
159
|
-
function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (/^https
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
return new URL(path, siteUrl).toString();
|
|
55
|
+
// 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();
|
|
167
63
|
}
|
|
168
64
|
function createSocialMetadata({
|
|
169
65
|
canonicalPath,
|
|
@@ -173,26 +69,20 @@ function createSocialMetadata({
|
|
|
173
69
|
title,
|
|
174
70
|
type = "website"
|
|
175
71
|
}) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
title
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
const imageUrl = absoluteUrl(entry.url, manifest.site.url);
|
|
195
|
-
return {
|
|
72
|
+
let key = ogManifest?.routes?.[canonicalPath], rootKey = ogManifest?.routes?.["/"], entry = (key ? ogManifest?.entries?.[key] : void 0) ?? (rootKey ? ogManifest?.entries?.[rootKey] : void 0), url = absoluteUrl({ path: canonicalPath, siteUrl: manifest.site.url }), imageUrl = entry ? absoluteUrl({ path: entry.url, siteUrl: manifest.site.url }) : void 0;
|
|
73
|
+
return !entry || !imageUrl ? {
|
|
74
|
+
openGraph: {
|
|
75
|
+
description,
|
|
76
|
+
title,
|
|
77
|
+
type,
|
|
78
|
+
...url ? { url } : {}
|
|
79
|
+
},
|
|
80
|
+
twitter: {
|
|
81
|
+
card: "summary",
|
|
82
|
+
description,
|
|
83
|
+
title
|
|
84
|
+
}
|
|
85
|
+
} : {
|
|
196
86
|
openGraph: {
|
|
197
87
|
description,
|
|
198
88
|
images: [
|
|
@@ -206,7 +96,7 @@ function createSocialMetadata({
|
|
|
206
96
|
siteName: manifest.site.name,
|
|
207
97
|
title,
|
|
208
98
|
type,
|
|
209
|
-
url:
|
|
99
|
+
...url ? { url } : {}
|
|
210
100
|
},
|
|
211
101
|
twitter: {
|
|
212
102
|
card: "summary_large_image",
|
|
@@ -217,28 +107,24 @@ function createSocialMetadata({
|
|
|
217
107
|
};
|
|
218
108
|
}
|
|
219
109
|
|
|
220
|
-
// src/
|
|
110
|
+
// src/route-page-leaf.tsx
|
|
221
111
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
222
|
-
var manifests = /* @__PURE__ */ new Map();
|
|
223
|
-
var leaves = /* @__PURE__ */ new Map();
|
|
224
|
-
var poweredByFooters = /* @__PURE__ */ new Map();
|
|
112
|
+
var manifests = /* @__PURE__ */ new Map(), leaves = /* @__PURE__ */ new Map(), poweredByFooters = /* @__PURE__ */ new Map();
|
|
225
113
|
function hasClassName(value, className) {
|
|
226
|
-
return typeof value
|
|
114
|
+
return typeof value == "string" && value.split(/\s+/).includes(className);
|
|
227
115
|
}
|
|
228
116
|
function isPlatformMdx(value) {
|
|
229
|
-
return value === MDX || typeof value
|
|
117
|
+
return value === MDX || typeof value == "function" && value.__publishOsMdx === !0;
|
|
230
118
|
}
|
|
231
119
|
function findMdxPath(node) {
|
|
232
|
-
if (!isValidElement(node))
|
|
120
|
+
if (!isValidElement(node))
|
|
233
121
|
return null;
|
|
234
|
-
|
|
235
|
-
if (isPlatformMdx(node.type)) {
|
|
122
|
+
if (isPlatformMdx(node.type))
|
|
236
123
|
return [];
|
|
237
|
-
|
|
238
|
-
const children = Children.toArray(node.props.children);
|
|
124
|
+
let children = Children.toArray(node.props.children);
|
|
239
125
|
for (let index = 0; index < children.length; index += 1) {
|
|
240
|
-
|
|
241
|
-
if (childPath)
|
|
126
|
+
let childPath = findMdxPath(children[index]);
|
|
127
|
+
if (childPath)
|
|
242
128
|
return [
|
|
243
129
|
{
|
|
244
130
|
childIndex: index,
|
|
@@ -247,22 +133,19 @@ function findMdxPath(node) {
|
|
|
247
133
|
},
|
|
248
134
|
...childPath
|
|
249
135
|
];
|
|
250
|
-
}
|
|
251
136
|
}
|
|
252
137
|
return null;
|
|
253
138
|
}
|
|
254
139
|
function targetDepthForMdxPath(path) {
|
|
255
140
|
for (let index = path.length - 1; index >= 0; index -= 1) {
|
|
256
|
-
|
|
257
|
-
if (entry && entry.childIndex < entry.children.length - 1)
|
|
141
|
+
let entry = path[index];
|
|
142
|
+
if (entry && entry.childIndex < entry.children.length - 1)
|
|
258
143
|
return index;
|
|
259
|
-
}
|
|
260
144
|
}
|
|
261
145
|
for (let index = path.length - 1; index >= 0; index -= 1) {
|
|
262
|
-
|
|
263
|
-
if (!hasClassName(entry?.element.props.className, "markdown-prose"))
|
|
146
|
+
let entry = path[index];
|
|
147
|
+
if (!hasClassName(entry?.element.props.className, "markdown-prose"))
|
|
264
148
|
return index;
|
|
265
|
-
}
|
|
266
149
|
}
|
|
267
150
|
return 0;
|
|
268
151
|
}
|
|
@@ -272,15 +155,12 @@ function appendFooterAtPath({
|
|
|
272
155
|
node,
|
|
273
156
|
targetPath
|
|
274
157
|
}) {
|
|
275
|
-
if (!isValidElement(node))
|
|
158
|
+
if (!isValidElement(node))
|
|
276
159
|
return node;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (currentPath.length === targetPath.length) {
|
|
160
|
+
let children = Children.toArray(node.props.children);
|
|
161
|
+
if (currentPath.length === targetPath.length)
|
|
280
162
|
return cloneElement(node, void 0, ...children, footer);
|
|
281
|
-
|
|
282
|
-
const childIndex = targetPath[currentPath.length];
|
|
283
|
-
const nextChildren = children.map(
|
|
163
|
+
let childIndex = targetPath[currentPath.length], nextChildren = children.map(
|
|
284
164
|
(child, index) => index === childIndex ? appendFooterAtPath({
|
|
285
165
|
currentPath: [...currentPath, index],
|
|
286
166
|
footer,
|
|
@@ -294,15 +174,13 @@ function appendPoweredByFooter({
|
|
|
294
174
|
footer,
|
|
295
175
|
node
|
|
296
176
|
}) {
|
|
297
|
-
|
|
298
|
-
if (!path?.length)
|
|
299
|
-
return { node, placed:
|
|
300
|
-
|
|
301
|
-
const targetDepth = targetDepthForMdxPath(path);
|
|
302
|
-
const targetPath = path.slice(0, targetDepth).map((entry) => entry.childIndex);
|
|
177
|
+
let path = findMdxPath(node);
|
|
178
|
+
if (!path?.length)
|
|
179
|
+
return { node, placed: !1 };
|
|
180
|
+
let targetDepth = targetDepthForMdxPath(path), targetPath = path.slice(0, targetDepth).map((entry) => entry.childIndex);
|
|
303
181
|
return {
|
|
304
182
|
node: appendFooterAtPath({ footer, node, targetPath }),
|
|
305
|
-
placed:
|
|
183
|
+
placed: !0
|
|
306
184
|
};
|
|
307
185
|
}
|
|
308
186
|
async function CachedLeafPage({
|
|
@@ -310,25 +188,17 @@ async function CachedLeafPage({
|
|
|
310
188
|
slug
|
|
311
189
|
}) {
|
|
312
190
|
"use cache";
|
|
313
|
-
cacheLife("page")
|
|
314
|
-
cacheTag(
|
|
191
|
+
cacheLife("page"), cacheTag(
|
|
315
192
|
tags.site(),
|
|
316
193
|
tags.pages(),
|
|
317
194
|
tags.group(group),
|
|
318
195
|
tags.page(group, slug)
|
|
319
196
|
);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
log.debug("[cache]", `${group}/${slug.join("/")}`);
|
|
326
|
-
const resolved = resolveLeaf(manifest, group, slug);
|
|
327
|
-
if (!resolved) notFound();
|
|
328
|
-
const attribution = manifest.attribution?.[group] ?? { enabled: false };
|
|
329
|
-
const leaf = await Leaf(resolved);
|
|
330
|
-
const footer = attribution.enabled && PoweredByFooter ? /* @__PURE__ */ jsx(PoweredByFooter, { attribution }) : null;
|
|
331
|
-
const placed = footer ? appendPoweredByFooter({ footer, node: leaf }) : { node: leaf, placed: true };
|
|
197
|
+
let manifest = manifests.get(group), Leaf = leaves.get(group), PoweredByFooter = poweredByFooters.get(group);
|
|
198
|
+
(!manifest || !Leaf) && notFound(), cacheTag(tags.manifest(manifest.contentHash)), log.debug("[cache]", `${group}/${slug.join("/")}`);
|
|
199
|
+
let resolved = resolveLeaf(manifest, group, slug);
|
|
200
|
+
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 };
|
|
332
202
|
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-full min-w-0 flex-1 flex-col", children: [
|
|
333
203
|
placed.node,
|
|
334
204
|
footer && !placed.placed ? footer : null
|
|
@@ -340,17 +210,9 @@ function createLeafPage({
|
|
|
340
210
|
Leaf,
|
|
341
211
|
PoweredByFooter
|
|
342
212
|
}) {
|
|
343
|
-
manifests.set(group, manifest)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
poweredByFooters.set(group, PoweredByFooter);
|
|
347
|
-
} else {
|
|
348
|
-
poweredByFooters.delete(group);
|
|
349
|
-
}
|
|
350
|
-
return async function Page({ params }) {
|
|
351
|
-
const { slug = [] } = await params;
|
|
352
|
-
log.debug("[render]", `${group}/${slug.join("/")}`);
|
|
353
|
-
return /* @__PURE__ */ jsx(CachedLeafPage, { group, slug });
|
|
213
|
+
return manifests.set(group, manifest), leaves.set(group, Leaf), PoweredByFooter ? poweredByFooters.set(group, PoweredByFooter) : poweredByFooters.delete(group), async function({ params }) {
|
|
214
|
+
let { slug = [] } = await params;
|
|
215
|
+
return log.debug("[render]", `${group}/${slug.join("/")}`), /* @__PURE__ */ jsx(CachedLeafPage, { group, slug });
|
|
354
216
|
};
|
|
355
217
|
}
|
|
356
218
|
function createLeafMetadata({
|
|
@@ -358,14 +220,13 @@ function createLeafMetadata({
|
|
|
358
220
|
manifest,
|
|
359
221
|
ogManifest
|
|
360
222
|
}) {
|
|
361
|
-
return async function
|
|
223
|
+
return async function({
|
|
362
224
|
params
|
|
363
225
|
}) {
|
|
364
|
-
|
|
226
|
+
let { slug = [] } = await params;
|
|
365
227
|
log.debug("[metadata]", `${group}/${slug.join("/")}`);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return {
|
|
228
|
+
let resolved = resolveLeaf(manifest, group, slug);
|
|
229
|
+
return resolved ? {
|
|
369
230
|
title: resolved.page.title,
|
|
370
231
|
description: resolved.page.description,
|
|
371
232
|
alternates: agentReadableAlternates({
|
|
@@ -381,11 +242,11 @@ function createLeafMetadata({
|
|
|
381
242
|
title: resolved.page.title,
|
|
382
243
|
type: "article"
|
|
383
244
|
})
|
|
384
|
-
};
|
|
245
|
+
} : {};
|
|
385
246
|
};
|
|
386
247
|
}
|
|
387
248
|
function createLeafStaticParams({ group, manifest }) {
|
|
388
|
-
return function
|
|
249
|
+
return function() {
|
|
389
250
|
return listStaticParams(manifest, group);
|
|
390
251
|
};
|
|
391
252
|
}
|
|
@@ -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 { O as OgManifestLike } from '../../../route-metadata-og-image-BeKKFHg7.js';
|
|
4
5
|
import { RootPageProps, ManifestLike } from '../../../types.js';
|
|
5
|
-
import { OgManifestLike } from '../metadata/og-image.js';
|
|
6
6
|
|
|
7
7
|
type RootPageComponent = (props: RootPageProps) => ReactElement | Promise<ReactElement>;
|
|
8
8
|
type RootRouteConfig = {
|
|
@@ -1,64 +1,11 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/route-page-root.tsx
|
|
2
|
+
import { tags } from "@publish.os/nextjs/cache/tags";
|
|
2
3
|
import { cacheLife, cacheTag } from "next/cache";
|
|
3
4
|
|
|
4
|
-
// src/
|
|
5
|
-
|
|
6
|
-
var MAX_TAG_LEN = 256;
|
|
7
|
-
var MAX_SEGMENT_LEN = 80;
|
|
8
|
-
var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
|
|
9
|
-
function sha256(value) {
|
|
10
|
-
return createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
11
|
-
}
|
|
12
|
-
function safeSegment(value) {
|
|
13
|
-
const raw = value.trim().toLowerCase() || "root";
|
|
14
|
-
const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
15
|
-
const segment = normalized || "root";
|
|
16
|
-
if (segment.length <= MAX_SEGMENT_LEN) return segment;
|
|
17
|
-
return `${segment.slice(0, 48)}.${sha256(segment)}`;
|
|
18
|
-
}
|
|
19
|
-
function assertTag(tag) {
|
|
20
|
-
if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
|
|
21
|
-
return `tag:${sha256(tag)}`;
|
|
22
|
-
}
|
|
23
|
-
return tag;
|
|
24
|
-
}
|
|
25
|
-
var tags = {
|
|
26
|
-
site() {
|
|
27
|
-
return "site";
|
|
28
|
-
},
|
|
29
|
-
pages() {
|
|
30
|
-
return "pages";
|
|
31
|
-
},
|
|
32
|
-
group(group) {
|
|
33
|
-
return assertTag(`group:${safeSegment(group)}`);
|
|
34
|
-
},
|
|
35
|
-
page(group, slug) {
|
|
36
|
-
const path = Array.isArray(slug) ? slug.join("/") : slug;
|
|
37
|
-
return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
|
|
38
|
-
},
|
|
39
|
-
manifest(contentHash) {
|
|
40
|
-
return assertTag(`manifest:${safeSegment(contentHash)}`);
|
|
41
|
-
},
|
|
42
|
-
sitemap() {
|
|
43
|
-
return "sitemap";
|
|
44
|
-
},
|
|
45
|
-
robots() {
|
|
46
|
-
return "robots";
|
|
47
|
-
},
|
|
48
|
-
llms(scope = "root") {
|
|
49
|
-
return assertTag(`llms:${safeSegment(scope)}`);
|
|
50
|
-
},
|
|
51
|
-
feed(format, scope = "site") {
|
|
52
|
-
return assertTag(`feed:${safeSegment(format)}:${safeSegment(scope)}`);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/internal/utils/logger.ts
|
|
57
|
-
var isDev = process.env.NODE_ENV !== "production";
|
|
58
|
-
var isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1";
|
|
59
|
-
var log = {
|
|
5
|
+
// src/lib/runtime/logging/logger.ts
|
|
6
|
+
var isDev = process.env.NODE_ENV !== "production", isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1", log = {
|
|
60
7
|
debug(...args) {
|
|
61
|
-
|
|
8
|
+
isDev && isDebugEnabled && console.debug("[publish.os:debug]", ...args);
|
|
62
9
|
},
|
|
63
10
|
info(...args) {
|
|
64
11
|
console.log("[publish.os]", ...args);
|
|
@@ -71,11 +18,10 @@ var log = {
|
|
|
71
18
|
}
|
|
72
19
|
};
|
|
73
20
|
|
|
74
|
-
// src/
|
|
21
|
+
// src/lib/runtime/metadata/agent-metadata.ts
|
|
75
22
|
function normalizePath(path) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return prefixed.replace(/\/+$/, "");
|
|
23
|
+
let prefixed = path.startsWith("/") ? path : `/${path}`;
|
|
24
|
+
return prefixed === "/" ? prefixed : prefixed.replace(/\/+$/, "");
|
|
79
25
|
}
|
|
80
26
|
function agentReadableAlternates({
|
|
81
27
|
canonicalPath,
|
|
@@ -91,15 +37,14 @@ function agentReadableAlternates({
|
|
|
91
37
|
};
|
|
92
38
|
}
|
|
93
39
|
|
|
94
|
-
// src/
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (/^https
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
return new URL(path, siteUrl).toString();
|
|
40
|
+
// 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();
|
|
103
48
|
}
|
|
104
49
|
function createSocialMetadata({
|
|
105
50
|
canonicalPath,
|
|
@@ -109,26 +54,20 @@ function createSocialMetadata({
|
|
|
109
54
|
title,
|
|
110
55
|
type = "website"
|
|
111
56
|
}) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
title
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const imageUrl = absoluteUrl(entry.url, manifest.site.url);
|
|
131
|
-
return {
|
|
57
|
+
let key = ogManifest?.routes?.[canonicalPath], rootKey = ogManifest?.routes?.["/"], entry = (key ? ogManifest?.entries?.[key] : void 0) ?? (rootKey ? ogManifest?.entries?.[rootKey] : void 0), url = absoluteUrl({ path: canonicalPath, siteUrl: manifest.site.url }), imageUrl = entry ? absoluteUrl({ path: entry.url, siteUrl: manifest.site.url }) : void 0;
|
|
58
|
+
return !entry || !imageUrl ? {
|
|
59
|
+
openGraph: {
|
|
60
|
+
description,
|
|
61
|
+
title,
|
|
62
|
+
type,
|
|
63
|
+
...url ? { url } : {}
|
|
64
|
+
},
|
|
65
|
+
twitter: {
|
|
66
|
+
card: "summary",
|
|
67
|
+
description,
|
|
68
|
+
title
|
|
69
|
+
}
|
|
70
|
+
} : {
|
|
132
71
|
openGraph: {
|
|
133
72
|
description,
|
|
134
73
|
images: [
|
|
@@ -142,7 +81,7 @@ function createSocialMetadata({
|
|
|
142
81
|
siteName: manifest.site.name,
|
|
143
82
|
title,
|
|
144
83
|
type,
|
|
145
|
-
url:
|
|
84
|
+
...url ? { url } : {}
|
|
146
85
|
},
|
|
147
86
|
twitter: {
|
|
148
87
|
card: "summary_large_image",
|
|
@@ -153,33 +92,23 @@ function createSocialMetadata({
|
|
|
153
92
|
};
|
|
154
93
|
}
|
|
155
94
|
|
|
156
|
-
// src/
|
|
95
|
+
// src/route-page-root.tsx
|
|
157
96
|
import { jsx } from "react/jsx-runtime";
|
|
158
|
-
var rootManifest;
|
|
159
|
-
var rootPage;
|
|
97
|
+
var rootManifest, rootPage;
|
|
160
98
|
async function CachedRootPage() {
|
|
161
99
|
"use cache";
|
|
162
|
-
cacheLife("page");
|
|
163
|
-
cacheTag(tags.site());
|
|
164
|
-
if (!rootManifest || !rootPage) return null;
|
|
165
|
-
cacheTag(tags.manifest(rootManifest.contentHash));
|
|
166
|
-
log.debug("[cache]", "root");
|
|
167
|
-
const RootPage = rootPage;
|
|
168
|
-
return /* @__PURE__ */ jsx(RootPage, { site: rootManifest.site, tree: rootManifest.tree });
|
|
100
|
+
return cacheLife("page"), cacheTag(tags.site()), !rootManifest || !rootPage ? null : (cacheTag(tags.manifest(rootManifest.contentHash)), log.debug("[cache]", "root"), /* @__PURE__ */ jsx(rootPage, { site: rootManifest.site, tree: rootManifest.tree }));
|
|
169
101
|
}
|
|
170
102
|
function createRootPage({ manifest, RootPage }) {
|
|
171
|
-
rootManifest = manifest
|
|
172
|
-
|
|
173
|
-
return async function Page() {
|
|
174
|
-
log.debug("[render]", "root");
|
|
175
|
-
return /* @__PURE__ */ jsx(CachedRootPage, {});
|
|
103
|
+
return rootManifest = manifest, rootPage = RootPage, async function() {
|
|
104
|
+
return log.debug("[render]", "root"), /* @__PURE__ */ jsx(CachedRootPage, {});
|
|
176
105
|
};
|
|
177
106
|
}
|
|
178
107
|
function createRootMetadata({
|
|
179
108
|
manifest,
|
|
180
109
|
ogManifest
|
|
181
110
|
}) {
|
|
182
|
-
|
|
111
|
+
let description = manifest.site.description;
|
|
183
112
|
return {
|
|
184
113
|
title: manifest.site.name,
|
|
185
114
|
description,
|