@publish.os/nextjs 0.0.1-alpha.1
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 +7 -0
- package/dist/cache/tags.cjs +76 -0
- package/dist/cache/tags.d.cts +12 -0
- package/dist/cache/tags.d.ts +12 -0
- package/dist/cache/tags.js +51 -0
- package/dist/components/color-palette.cjs +408 -0
- package/dist/components/color-palette.d.cts +5 -0
- package/dist/components/color-palette.d.ts +5 -0
- package/dist/components/color-palette.js +388 -0
- package/dist/components/nav-breadcrumb.cjs +141 -0
- package/dist/components/nav-breadcrumb.d.cts +9 -0
- package/dist/components/nav-breadcrumb.d.ts +9 -0
- package/dist/components/nav-breadcrumb.js +107 -0
- package/dist/components/page-list.cjs +68 -0
- package/dist/components/page-list.d.cts +11 -0
- package/dist/components/page-list.d.ts +11 -0
- package/dist/components/page-list.js +33 -0
- package/dist/components/providers.cjs +44 -0
- package/dist/components/providers.d.cts +8 -0
- package/dist/components/providers.d.ts +8 -0
- package/dist/components/providers.js +20 -0
- package/dist/components/site-header.cjs +302 -0
- package/dist/components/site-header.d.cts +12 -0
- package/dist/components/site-header.d.ts +12 -0
- package/dist/components/site-header.js +268 -0
- package/dist/components/theme-toggle.cjs +147 -0
- package/dist/components/theme-toggle.d.cts +5 -0
- package/dist/components/theme-toggle.d.ts +5 -0
- package/dist/components/theme-toggle.js +123 -0
- package/dist/config/createNextConfig.cjs +52 -0
- package/dist/config/createNextConfig.d.cts +8 -0
- package/dist/config/createNextConfig.d.ts +8 -0
- package/dist/config/createNextConfig.js +27 -0
- package/dist/index.cjs +347 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +299 -0
- package/dist/layouts/group.cjs +157 -0
- package/dist/layouts/group.d.cts +15 -0
- package/dist/layouts/group.d.ts +15 -0
- package/dist/layouts/group.js +132 -0
- package/dist/mdx/error-boundary.cjs +94 -0
- package/dist/mdx/error-boundary.d.cts +13 -0
- package/dist/mdx/error-boundary.d.ts +13 -0
- package/dist/mdx/error-boundary.js +70 -0
- package/dist/mdx/error-fallback.cjs +58 -0
- package/dist/mdx/error-fallback.d.cts +9 -0
- package/dist/mdx/error-fallback.d.ts +9 -0
- package/dist/mdx/error-fallback.js +33 -0
- package/dist/mdx/mdx.cjs +182 -0
- package/dist/mdx/mdx.d.cts +10 -0
- package/dist/mdx/mdx.d.ts +10 -0
- package/dist/mdx/mdx.js +147 -0
- package/dist/pages/group.cjs +162 -0
- package/dist/pages/group.d.cts +15 -0
- package/dist/pages/group.d.ts +15 -0
- package/dist/pages/group.js +136 -0
- package/dist/pages/leaf.cjs +203 -0
- package/dist/pages/leaf.d.cts +23 -0
- package/dist/pages/leaf.d.ts +23 -0
- package/dist/pages/leaf.js +176 -0
- package/dist/pages/root.cjs +127 -0
- package/dist/pages/root.d.cts +14 -0
- package/dist/pages/root.d.ts +14 -0
- package/dist/pages/root.js +101 -0
- package/dist/resolvers/manifest-resolver.cjs +107 -0
- package/dist/resolvers/manifest-resolver.d.cts +13 -0
- package/dist/resolvers/manifest-resolver.d.ts +13 -0
- package/dist/resolvers/manifest-resolver.js +79 -0
- package/dist/routes/llms.cjs +101 -0
- package/dist/routes/llms.d.cts +7 -0
- package/dist/routes/llms.d.ts +7 -0
- package/dist/routes/llms.js +76 -0
- package/dist/routes/robots.cjs +94 -0
- package/dist/routes/robots.d.cts +5 -0
- package/dist/routes/robots.d.ts +5 -0
- package/dist/routes/robots.js +69 -0
- package/dist/routes/sitemap.cjs +108 -0
- package/dist/routes/sitemap.d.cts +5 -0
- package/dist/routes/sitemap.d.ts +5 -0
- package/dist/routes/sitemap.js +83 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +144 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +0 -0
- package/dist/utils/cn.cjs +49 -0
- package/dist/utils/cn.d.cts +15 -0
- package/dist/utils/cn.d.ts +15 -0
- package/dist/utils/cn.js +24 -0
- package/dist/utils/pretty-date.cjs +55 -0
- package/dist/utils/pretty-date.d.cts +6 -0
- package/dist/utils/pretty-date.d.ts +6 -0
- package/dist/utils/pretty-date.js +30 -0
- package/package.json +100 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/routes/sitemap.ts
|
|
21
|
+
var sitemap_exports = {};
|
|
22
|
+
__export(sitemap_exports, {
|
|
23
|
+
createSitemapXmlRoute: () => createSitemapXmlRoute
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sitemap_exports);
|
|
26
|
+
var import_cache = require("next/cache");
|
|
27
|
+
|
|
28
|
+
// src/cache/tags.ts
|
|
29
|
+
var import_node_crypto = require("crypto");
|
|
30
|
+
var MAX_TAG_LEN = 256;
|
|
31
|
+
var MAX_SEGMENT_LEN = 80;
|
|
32
|
+
var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
|
|
33
|
+
function sha256(value) {
|
|
34
|
+
return (0, import_node_crypto.createHash)("sha256").update(value).digest("hex").slice(0, 16);
|
|
35
|
+
}
|
|
36
|
+
function safeSegment(value) {
|
|
37
|
+
const raw = value.trim().toLowerCase() || "root";
|
|
38
|
+
const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
39
|
+
const segment = normalized || "root";
|
|
40
|
+
if (segment.length <= MAX_SEGMENT_LEN) return segment;
|
|
41
|
+
return `${segment.slice(0, 48)}.${sha256(segment)}`;
|
|
42
|
+
}
|
|
43
|
+
function assertTag(tag) {
|
|
44
|
+
if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
|
|
45
|
+
return `tag:${sha256(tag)}`;
|
|
46
|
+
}
|
|
47
|
+
return tag;
|
|
48
|
+
}
|
|
49
|
+
var tags = {
|
|
50
|
+
site() {
|
|
51
|
+
return "site";
|
|
52
|
+
},
|
|
53
|
+
pages() {
|
|
54
|
+
return "pages";
|
|
55
|
+
},
|
|
56
|
+
group(group) {
|
|
57
|
+
return assertTag(`group:${safeSegment(group)}`);
|
|
58
|
+
},
|
|
59
|
+
page(group, slug) {
|
|
60
|
+
const path = Array.isArray(slug) ? slug.join("/") : slug;
|
|
61
|
+
return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
|
|
62
|
+
},
|
|
63
|
+
manifest(contentHash) {
|
|
64
|
+
return assertTag(`manifest:${safeSegment(contentHash)}`);
|
|
65
|
+
},
|
|
66
|
+
sitemap() {
|
|
67
|
+
return "sitemap";
|
|
68
|
+
},
|
|
69
|
+
robots() {
|
|
70
|
+
return "robots";
|
|
71
|
+
},
|
|
72
|
+
llms(scope = "root") {
|
|
73
|
+
return assertTag(`llms:${safeSegment(scope)}`);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/routes/sitemap.ts
|
|
78
|
+
function xmlEscape(value) {
|
|
79
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
80
|
+
}
|
|
81
|
+
async function sitemapXml(manifest) {
|
|
82
|
+
"use cache";
|
|
83
|
+
(0, import_cache.cacheLife)("page");
|
|
84
|
+
(0, import_cache.cacheTag)(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
|
|
85
|
+
const urls = [
|
|
86
|
+
"/",
|
|
87
|
+
...Object.values(manifest.groups).map((g) => g.path),
|
|
88
|
+
...manifest.pages.filter((page) => page.status === "published").map((page) => page.path)
|
|
89
|
+
];
|
|
90
|
+
const uniqueUrls = [...new Set(urls)];
|
|
91
|
+
const body = uniqueUrls.map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join("\n");
|
|
92
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
93
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
94
|
+
${body}
|
|
95
|
+
</urlset>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
function createSitemapXmlRoute(manifest) {
|
|
99
|
+
return async function GET() {
|
|
100
|
+
return new Response(await sitemapXml(manifest), {
|
|
101
|
+
headers: { "content-type": "application/xml; charset=utf-8" }
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
createSitemapXmlRoute
|
|
108
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/routes/sitemap.ts
|
|
2
|
+
import { cacheLife, cacheTag } from "next/cache";
|
|
3
|
+
|
|
4
|
+
// src/cache/tags.ts
|
|
5
|
+
import { createHash } from "crypto";
|
|
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
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/routes/sitemap.ts
|
|
54
|
+
function xmlEscape(value) {
|
|
55
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
56
|
+
}
|
|
57
|
+
async function sitemapXml(manifest) {
|
|
58
|
+
"use cache";
|
|
59
|
+
cacheLife("page");
|
|
60
|
+
cacheTag(tags.site(), tags.sitemap(), tags.manifest(manifest.contentHash));
|
|
61
|
+
const urls = [
|
|
62
|
+
"/",
|
|
63
|
+
...Object.values(manifest.groups).map((g) => g.path),
|
|
64
|
+
...manifest.pages.filter((page) => page.status === "published").map((page) => page.path)
|
|
65
|
+
];
|
|
66
|
+
const uniqueUrls = [...new Set(urls)];
|
|
67
|
+
const body = uniqueUrls.map((url) => ` <url><loc>${xmlEscape(url)}</loc></url>`).join("\n");
|
|
68
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
69
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
70
|
+
${body}
|
|
71
|
+
</urlset>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
function createSitemapXmlRoute(manifest) {
|
|
75
|
+
return async function GET() {
|
|
76
|
+
return new Response(await sitemapXml(manifest), {
|
|
77
|
+
headers: { "content-type": "application/xml; charset=utf-8" }
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
createSitemapXmlRoute
|
|
83
|
+
};
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
type Heading = {
|
|
2
|
+
id: string;
|
|
3
|
+
depth: number;
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
type SiteData = {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
type Author = {
|
|
11
|
+
id?: string;
|
|
12
|
+
name: string;
|
|
13
|
+
handle?: string;
|
|
14
|
+
avatar?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
};
|
|
17
|
+
type PageStatus = "published" | "draft" | "archived";
|
|
18
|
+
type PageFrontmatter = {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
slug?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
status?: PageStatus;
|
|
24
|
+
publishedAt?: string;
|
|
25
|
+
updatedAt?: string;
|
|
26
|
+
authors?: (string | Author)[];
|
|
27
|
+
tags?: string[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
type PageData<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
31
|
+
id: string;
|
|
32
|
+
group: string;
|
|
33
|
+
slug: string;
|
|
34
|
+
path: string;
|
|
35
|
+
title: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
status: PageStatus;
|
|
38
|
+
publishedAt?: string;
|
|
39
|
+
updatedAt?: string;
|
|
40
|
+
authors: Author[];
|
|
41
|
+
tags: string[];
|
|
42
|
+
meta: TMeta;
|
|
43
|
+
body: string;
|
|
44
|
+
};
|
|
45
|
+
type PageSummary<TMeta extends Record<string, unknown> = Record<string, unknown>> = Omit<PageData<TMeta>, "body"> & {
|
|
46
|
+
body?: string;
|
|
47
|
+
};
|
|
48
|
+
type PageNode = {
|
|
49
|
+
type: "page";
|
|
50
|
+
id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
path: string;
|
|
53
|
+
group: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
status: PageStatus;
|
|
56
|
+
publishedAt?: string;
|
|
57
|
+
updatedAt?: string;
|
|
58
|
+
authors: Author[];
|
|
59
|
+
tags?: string[];
|
|
60
|
+
meta: Record<string, unknown>;
|
|
61
|
+
};
|
|
62
|
+
type SectionNode = {
|
|
63
|
+
type: "section";
|
|
64
|
+
id: string;
|
|
65
|
+
title: string;
|
|
66
|
+
path?: string;
|
|
67
|
+
group?: string;
|
|
68
|
+
children: TreeNode[];
|
|
69
|
+
};
|
|
70
|
+
type FolderNode = {
|
|
71
|
+
type: "folder";
|
|
72
|
+
id: string;
|
|
73
|
+
title: string;
|
|
74
|
+
group?: string;
|
|
75
|
+
children: TreeNode[];
|
|
76
|
+
};
|
|
77
|
+
type LinkNode = {
|
|
78
|
+
type: "link";
|
|
79
|
+
id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
href: string;
|
|
82
|
+
};
|
|
83
|
+
type TreeNode = PageNode | SectionNode | FolderNode | LinkNode;
|
|
84
|
+
type NavPage = PageNode;
|
|
85
|
+
type NavLink = LinkNode;
|
|
86
|
+
type NavSection = SectionNode;
|
|
87
|
+
type NavFolder = FolderNode;
|
|
88
|
+
type NavItem = TreeNode;
|
|
89
|
+
type RouteRecord = {
|
|
90
|
+
id: string;
|
|
91
|
+
slug: string;
|
|
92
|
+
path: string;
|
|
93
|
+
group: string;
|
|
94
|
+
};
|
|
95
|
+
type GroupManifest = {
|
|
96
|
+
key: string;
|
|
97
|
+
title: string;
|
|
98
|
+
path: string;
|
|
99
|
+
contentDir: string;
|
|
100
|
+
tree: TreeNode[];
|
|
101
|
+
pages: PageData[];
|
|
102
|
+
};
|
|
103
|
+
type ManifestLike = {
|
|
104
|
+
site: SiteData;
|
|
105
|
+
groups: Record<string, GroupManifest>;
|
|
106
|
+
routes: RouteRecord[];
|
|
107
|
+
pages: PageData[];
|
|
108
|
+
tree: TreeNode[];
|
|
109
|
+
contentHash: string;
|
|
110
|
+
};
|
|
111
|
+
type RootLayoutProps = {
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
site: SiteData;
|
|
114
|
+
tree: TreeNode[];
|
|
115
|
+
};
|
|
116
|
+
type RootPageProps = {
|
|
117
|
+
site: SiteData;
|
|
118
|
+
tree: TreeNode[];
|
|
119
|
+
};
|
|
120
|
+
type LayoutProps = {
|
|
121
|
+
children: React.ReactNode;
|
|
122
|
+
site: SiteData;
|
|
123
|
+
tree: TreeNode[];
|
|
124
|
+
node: TreeNode;
|
|
125
|
+
currentPath: string;
|
|
126
|
+
group: string;
|
|
127
|
+
};
|
|
128
|
+
type PageProps<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
129
|
+
site: SiteData;
|
|
130
|
+
tree: TreeNode[];
|
|
131
|
+
node: TreeNode;
|
|
132
|
+
page: PageData<TMeta>;
|
|
133
|
+
currentPath: string;
|
|
134
|
+
group: string;
|
|
135
|
+
};
|
|
136
|
+
type IndexPageProps = {
|
|
137
|
+
site: SiteData;
|
|
138
|
+
tree: TreeNode[];
|
|
139
|
+
node: TreeNode;
|
|
140
|
+
currentPath: string;
|
|
141
|
+
group: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type { Author, FolderNode, GroupManifest, Heading, IndexPageProps, LayoutProps, LinkNode, ManifestLike, NavFolder, NavItem, NavLink, NavPage, NavSection, PageData, PageFrontmatter, PageNode, PageProps, PageStatus, PageSummary, RootLayoutProps, RootPageProps, RouteRecord, SectionNode, SiteData, TreeNode };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
type Heading = {
|
|
2
|
+
id: string;
|
|
3
|
+
depth: number;
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
type SiteData = {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
type Author = {
|
|
11
|
+
id?: string;
|
|
12
|
+
name: string;
|
|
13
|
+
handle?: string;
|
|
14
|
+
avatar?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
};
|
|
17
|
+
type PageStatus = "published" | "draft" | "archived";
|
|
18
|
+
type PageFrontmatter = {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
slug?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
status?: PageStatus;
|
|
24
|
+
publishedAt?: string;
|
|
25
|
+
updatedAt?: string;
|
|
26
|
+
authors?: (string | Author)[];
|
|
27
|
+
tags?: string[];
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
type PageData<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
31
|
+
id: string;
|
|
32
|
+
group: string;
|
|
33
|
+
slug: string;
|
|
34
|
+
path: string;
|
|
35
|
+
title: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
status: PageStatus;
|
|
38
|
+
publishedAt?: string;
|
|
39
|
+
updatedAt?: string;
|
|
40
|
+
authors: Author[];
|
|
41
|
+
tags: string[];
|
|
42
|
+
meta: TMeta;
|
|
43
|
+
body: string;
|
|
44
|
+
};
|
|
45
|
+
type PageSummary<TMeta extends Record<string, unknown> = Record<string, unknown>> = Omit<PageData<TMeta>, "body"> & {
|
|
46
|
+
body?: string;
|
|
47
|
+
};
|
|
48
|
+
type PageNode = {
|
|
49
|
+
type: "page";
|
|
50
|
+
id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
path: string;
|
|
53
|
+
group: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
status: PageStatus;
|
|
56
|
+
publishedAt?: string;
|
|
57
|
+
updatedAt?: string;
|
|
58
|
+
authors: Author[];
|
|
59
|
+
tags?: string[];
|
|
60
|
+
meta: Record<string, unknown>;
|
|
61
|
+
};
|
|
62
|
+
type SectionNode = {
|
|
63
|
+
type: "section";
|
|
64
|
+
id: string;
|
|
65
|
+
title: string;
|
|
66
|
+
path?: string;
|
|
67
|
+
group?: string;
|
|
68
|
+
children: TreeNode[];
|
|
69
|
+
};
|
|
70
|
+
type FolderNode = {
|
|
71
|
+
type: "folder";
|
|
72
|
+
id: string;
|
|
73
|
+
title: string;
|
|
74
|
+
group?: string;
|
|
75
|
+
children: TreeNode[];
|
|
76
|
+
};
|
|
77
|
+
type LinkNode = {
|
|
78
|
+
type: "link";
|
|
79
|
+
id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
href: string;
|
|
82
|
+
};
|
|
83
|
+
type TreeNode = PageNode | SectionNode | FolderNode | LinkNode;
|
|
84
|
+
type NavPage = PageNode;
|
|
85
|
+
type NavLink = LinkNode;
|
|
86
|
+
type NavSection = SectionNode;
|
|
87
|
+
type NavFolder = FolderNode;
|
|
88
|
+
type NavItem = TreeNode;
|
|
89
|
+
type RouteRecord = {
|
|
90
|
+
id: string;
|
|
91
|
+
slug: string;
|
|
92
|
+
path: string;
|
|
93
|
+
group: string;
|
|
94
|
+
};
|
|
95
|
+
type GroupManifest = {
|
|
96
|
+
key: string;
|
|
97
|
+
title: string;
|
|
98
|
+
path: string;
|
|
99
|
+
contentDir: string;
|
|
100
|
+
tree: TreeNode[];
|
|
101
|
+
pages: PageData[];
|
|
102
|
+
};
|
|
103
|
+
type ManifestLike = {
|
|
104
|
+
site: SiteData;
|
|
105
|
+
groups: Record<string, GroupManifest>;
|
|
106
|
+
routes: RouteRecord[];
|
|
107
|
+
pages: PageData[];
|
|
108
|
+
tree: TreeNode[];
|
|
109
|
+
contentHash: string;
|
|
110
|
+
};
|
|
111
|
+
type RootLayoutProps = {
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
site: SiteData;
|
|
114
|
+
tree: TreeNode[];
|
|
115
|
+
};
|
|
116
|
+
type RootPageProps = {
|
|
117
|
+
site: SiteData;
|
|
118
|
+
tree: TreeNode[];
|
|
119
|
+
};
|
|
120
|
+
type LayoutProps = {
|
|
121
|
+
children: React.ReactNode;
|
|
122
|
+
site: SiteData;
|
|
123
|
+
tree: TreeNode[];
|
|
124
|
+
node: TreeNode;
|
|
125
|
+
currentPath: string;
|
|
126
|
+
group: string;
|
|
127
|
+
};
|
|
128
|
+
type PageProps<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
129
|
+
site: SiteData;
|
|
130
|
+
tree: TreeNode[];
|
|
131
|
+
node: TreeNode;
|
|
132
|
+
page: PageData<TMeta>;
|
|
133
|
+
currentPath: string;
|
|
134
|
+
group: string;
|
|
135
|
+
};
|
|
136
|
+
type IndexPageProps = {
|
|
137
|
+
site: SiteData;
|
|
138
|
+
tree: TreeNode[];
|
|
139
|
+
node: TreeNode;
|
|
140
|
+
currentPath: string;
|
|
141
|
+
group: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type { Author, FolderNode, GroupManifest, Heading, IndexPageProps, LayoutProps, LinkNode, ManifestLike, NavFolder, NavItem, NavLink, NavPage, NavSection, PageData, PageFrontmatter, PageNode, PageProps, PageStatus, PageSummary, RootLayoutProps, RootPageProps, RouteRecord, SectionNode, SiteData, TreeNode };
|
package/dist/types.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/cn.ts
|
|
21
|
+
var cn_exports = {};
|
|
22
|
+
__export(cn_exports, {
|
|
23
|
+
cn: () => cn
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cn_exports);
|
|
26
|
+
var import_clsx = require("clsx");
|
|
27
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
28
|
+
var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
|
|
29
|
+
extend: {
|
|
30
|
+
classGroups: {
|
|
31
|
+
z: [
|
|
32
|
+
"z-content",
|
|
33
|
+
"z-nav",
|
|
34
|
+
"z-overlay",
|
|
35
|
+
"z-modal",
|
|
36
|
+
"z-search",
|
|
37
|
+
"z-toast",
|
|
38
|
+
"z-progress"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
function cn(...inputs) {
|
|
44
|
+
return twMerge((0, import_clsx.clsx)(inputs));
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
cn
|
|
49
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merges class names using clsx and tailwind-merge.
|
|
5
|
+
*
|
|
6
|
+
* Use this `cn` for all PublishOS runtime and tenant components
|
|
7
|
+
* to ensure proper class merging.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* cn("bg-surface-2", "bg-accent-1", "rounded-lg")
|
|
11
|
+
* // Result: "bg-accent-1 rounded-lg"
|
|
12
|
+
*/
|
|
13
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
14
|
+
|
|
15
|
+
export { cn };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merges class names using clsx and tailwind-merge.
|
|
5
|
+
*
|
|
6
|
+
* Use this `cn` for all PublishOS runtime and tenant components
|
|
7
|
+
* to ensure proper class merging.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* cn("bg-surface-2", "bg-accent-1", "rounded-lg")
|
|
11
|
+
* // Result: "bg-accent-1 rounded-lg"
|
|
12
|
+
*/
|
|
13
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
14
|
+
|
|
15
|
+
export { cn };
|
package/dist/utils/cn.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/utils/cn.ts
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
4
|
+
var twMerge = extendTailwindMerge({
|
|
5
|
+
extend: {
|
|
6
|
+
classGroups: {
|
|
7
|
+
z: [
|
|
8
|
+
"z-content",
|
|
9
|
+
"z-nav",
|
|
10
|
+
"z-overlay",
|
|
11
|
+
"z-modal",
|
|
12
|
+
"z-search",
|
|
13
|
+
"z-toast",
|
|
14
|
+
"z-progress"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
function cn(...inputs) {
|
|
20
|
+
return twMerge(clsx(inputs));
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
cn
|
|
24
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/pretty-date.ts
|
|
21
|
+
var pretty_date_exports = {};
|
|
22
|
+
__export(pretty_date_exports, {
|
|
23
|
+
prettyDate: () => prettyDate
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(pretty_date_exports);
|
|
26
|
+
var defaultDateOptions = {
|
|
27
|
+
day: "numeric",
|
|
28
|
+
month: "short",
|
|
29
|
+
year: "numeric"
|
|
30
|
+
};
|
|
31
|
+
function parseDate(value) {
|
|
32
|
+
if (value instanceof Date) return value;
|
|
33
|
+
if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
34
|
+
return /* @__PURE__ */ new Date(`${value}T00:00:00`);
|
|
35
|
+
}
|
|
36
|
+
return new Date(value);
|
|
37
|
+
}
|
|
38
|
+
function prettyDate(value, options = {}) {
|
|
39
|
+
if (typeof value !== "string" && typeof value !== "number" && !(value instanceof Date)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const date = parseDate(value);
|
|
43
|
+
if (Number.isNaN(date.getTime())) {
|
|
44
|
+
return typeof value === "string" ? value : null;
|
|
45
|
+
}
|
|
46
|
+
const { locale = "en", ...dateOptions } = options;
|
|
47
|
+
return new Intl.DateTimeFormat(locale, {
|
|
48
|
+
...defaultDateOptions,
|
|
49
|
+
...dateOptions
|
|
50
|
+
}).format(date);
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
prettyDate
|
|
55
|
+
});
|