@headroom-cms/api 0.1.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 +477 -0
- package/blocks/BlockRenderer.astro +61 -0
- package/blocks/BulletList.astro +19 -0
- package/blocks/CheckList.astro +27 -0
- package/blocks/CodeBlock.astro +14 -0
- package/blocks/Fallback.astro +24 -0
- package/blocks/Heading.astro +17 -0
- package/blocks/Image.astro +31 -0
- package/blocks/InlineContent.astro +47 -0
- package/blocks/NumberedList.astro +19 -0
- package/blocks/Paragraph.astro +15 -0
- package/blocks/Table.astro +29 -0
- package/dist/astro.d.ts +49 -0
- package/dist/astro.js +325 -0
- package/dist/codegen.cjs +172 -0
- package/dist/codegen.d.cts +49 -0
- package/dist/codegen.d.ts +49 -0
- package/dist/codegen.js +144 -0
- package/dist/headroom-blocks.css +96 -0
- package/dist/index.cjs +202 -0
- package/dist/index.d.cts +227 -0
- package/dist/index.d.ts +227 -0
- package/dist/index.js +174 -0
- package/dist/react.cjs +323 -0
- package/dist/react.d.cts +105 -0
- package/dist/react.d.ts +105 -0
- package/dist/react.js +275 -0
- package/package.json +72 -0
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/react.ts
|
|
31
|
+
var react_exports = {};
|
|
32
|
+
__export(react_exports, {
|
|
33
|
+
BlockRenderer: () => BlockRenderer,
|
|
34
|
+
BulletList: () => BulletList,
|
|
35
|
+
CheckList: () => CheckList,
|
|
36
|
+
CodeBlock: () => CodeBlock,
|
|
37
|
+
Fallback: () => Fallback,
|
|
38
|
+
Heading: () => Heading,
|
|
39
|
+
ImageBlock: () => ImageBlock,
|
|
40
|
+
InlineContent: () => InlineContent,
|
|
41
|
+
NumberedList: () => NumberedList,
|
|
42
|
+
Paragraph: () => Paragraph,
|
|
43
|
+
Table: () => Table,
|
|
44
|
+
defaultBlockComponents: () => defaultBlockComponents
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(react_exports);
|
|
47
|
+
|
|
48
|
+
// src/react/InlineContent.tsx
|
|
49
|
+
var import_react = __toESM(require("react"), 1);
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
function styleClasses(styles) {
|
|
52
|
+
if (!styles) return void 0;
|
|
53
|
+
const classes = [];
|
|
54
|
+
if (styles.bold) classes.push("hr-bold");
|
|
55
|
+
if (styles.italic) classes.push("hr-italic");
|
|
56
|
+
if (styles.underline) classes.push("hr-underline");
|
|
57
|
+
if (styles.strikethrough) classes.push("hr-strikethrough");
|
|
58
|
+
if (styles.code) classes.push("hr-code");
|
|
59
|
+
return classes.length > 0 ? classes.join(" ") : void 0;
|
|
60
|
+
}
|
|
61
|
+
function resolveHref(href, refs, resolveContentLink) {
|
|
62
|
+
if (!href.startsWith("headroom://content/")) return href;
|
|
63
|
+
const match = href.match(/^headroom:\/\/content\/([^/]+)\/([A-Z0-9]+)$/);
|
|
64
|
+
if (!match) return "#";
|
|
65
|
+
const [, , contentId] = match;
|
|
66
|
+
const ref = refs?.[contentId];
|
|
67
|
+
if (!ref) return "#";
|
|
68
|
+
return resolveContentLink ? resolveContentLink(ref) : `/${ref.collection}/${ref.slug}`;
|
|
69
|
+
}
|
|
70
|
+
function InlineContent({ content, refs, resolveContentLink }) {
|
|
71
|
+
if (!content || content.length === 0) return null;
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content.map((item, i) => {
|
|
73
|
+
if (item.type === "link") {
|
|
74
|
+
const resolved = resolveHref(item.href, refs, resolveContentLink);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: resolved, className: "hr-link", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
76
|
+
InlineContent,
|
|
77
|
+
{
|
|
78
|
+
content: item.content,
|
|
79
|
+
refs,
|
|
80
|
+
resolveContentLink
|
|
81
|
+
}
|
|
82
|
+
) }, i);
|
|
83
|
+
}
|
|
84
|
+
const cls = styleClasses(item.styles);
|
|
85
|
+
return cls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: cls, children: item.text }, i) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: item.text }, i);
|
|
86
|
+
}) });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/react/blocks/Paragraph.tsx
|
|
90
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
91
|
+
function Paragraph({ block, refs, resolveContentLink }) {
|
|
92
|
+
const content = Array.isArray(block.content) ? block.content : [];
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "hr-paragraph", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(InlineContent, { content, refs, resolveContentLink }) });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/react/blocks/Heading.tsx
|
|
97
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
98
|
+
function Heading({ block, refs, resolveContentLink }) {
|
|
99
|
+
const level = Math.min(block.props?.level || 1, 6);
|
|
100
|
+
const content = Array.isArray(block.content) ? block.content : [];
|
|
101
|
+
const className = `hr-heading hr-h${level}`;
|
|
102
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InlineContent, { content, refs, resolveContentLink });
|
|
103
|
+
switch (level) {
|
|
104
|
+
case 1:
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { className, children: inner });
|
|
106
|
+
case 2:
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className, children: inner });
|
|
108
|
+
case 3:
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className, children: inner });
|
|
110
|
+
case 4:
|
|
111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h4", { className, children: inner });
|
|
112
|
+
case 5:
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h5", { className, children: inner });
|
|
114
|
+
case 6:
|
|
115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h6", { className, children: inner });
|
|
116
|
+
default:
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { className, children: inner });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/react/blocks/Image.tsx
|
|
122
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
123
|
+
function ImageBlock({ block, cdnUrl }) {
|
|
124
|
+
const storedPath = block.props?.url;
|
|
125
|
+
const src = storedPath ? cdnUrl ? `${cdnUrl}${storedPath}` : storedPath : "";
|
|
126
|
+
const alt = block.props?.alt || "";
|
|
127
|
+
const caption = block.props?.caption || "";
|
|
128
|
+
if (!src) return null;
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("figure", { className: "hr-image", children: [
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src, alt, loading: "lazy" }),
|
|
131
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("figcaption", { children: caption })
|
|
132
|
+
] });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/react/blocks/CodeBlock.tsx
|
|
136
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
137
|
+
function CodeBlock({ block }) {
|
|
138
|
+
const language = block.props?.language || "";
|
|
139
|
+
const content = Array.isArray(block.content) ? block.content : [];
|
|
140
|
+
const code = content.map((c) => "text" in c ? c.text : "").join("");
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: "hr-code-block", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { className: language ? `language-${language}` : "", children: code }) });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/react/blocks/BulletList.tsx
|
|
145
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
146
|
+
function BulletList({ items, refs, resolveContentLink }) {
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "hr-bullet-list", children: (items || []).map((item) => {
|
|
148
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InlineContent, { content, refs, resolveContentLink }) }, item.id);
|
|
150
|
+
}) });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/react/blocks/NumberedList.tsx
|
|
154
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
155
|
+
function NumberedList({ items, refs, resolveContentLink }) {
|
|
156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { className: "hr-numbered-list", children: (items || []).map((item) => {
|
|
157
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InlineContent, { content, refs, resolveContentLink }) }, item.id);
|
|
159
|
+
}) });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/react/blocks/CheckList.tsx
|
|
163
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
164
|
+
function CheckList({ items, refs, resolveContentLink }) {
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "hr-check-list", children: (items || []).map((item) => {
|
|
166
|
+
const checked = item.props?.checked;
|
|
167
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "hr-check-item", "data-checked": checked || void 0, children: [
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hr-checkbox", "aria-checked": checked, children: checked && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
170
|
+
"path",
|
|
171
|
+
{
|
|
172
|
+
d: "M4 8l3 3 5-6",
|
|
173
|
+
stroke: "currentColor",
|
|
174
|
+
strokeWidth: "2",
|
|
175
|
+
strokeLinecap: "round",
|
|
176
|
+
strokeLinejoin: "round"
|
|
177
|
+
}
|
|
178
|
+
) }) }),
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InlineContent, { content, refs, resolveContentLink }) })
|
|
180
|
+
] }, item.id);
|
|
181
|
+
}) });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/react/blocks/Table.tsx
|
|
185
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
186
|
+
function Table({ block, refs, resolveContentLink }) {
|
|
187
|
+
const tableContent = block.content;
|
|
188
|
+
const rows = tableContent?.rows || [];
|
|
189
|
+
if (rows.length === 0) return null;
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("table", { className: "hr-table", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tbody", { children: rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tr", { children: row.cells.map((cell, cellIndex) => {
|
|
191
|
+
const Tag = rowIndex === 0 ? "th" : "td";
|
|
192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tag, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InlineContent, { content: cell, refs, resolveContentLink }) }, cellIndex);
|
|
193
|
+
}) }, rowIndex)) }) });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/react/blocks/Fallback.tsx
|
|
197
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
198
|
+
function Fallback({ block, refs, resolveContentLink }) {
|
|
199
|
+
const content = Array.isArray(block.content) ? block.content : [];
|
|
200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hr-fallback", "data-block-type": block.type, children: [
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "hr-fallback-label", children: block.type }),
|
|
202
|
+
content.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InlineContent, { content, refs, resolveContentLink }) })
|
|
203
|
+
] });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/react/blocks/index.ts
|
|
207
|
+
var defaultBlockComponents = {
|
|
208
|
+
paragraph: Paragraph,
|
|
209
|
+
heading: Heading,
|
|
210
|
+
image: ImageBlock,
|
|
211
|
+
codeBlock: CodeBlock,
|
|
212
|
+
bulletList: BulletList,
|
|
213
|
+
numberedList: NumberedList,
|
|
214
|
+
checkList: CheckList,
|
|
215
|
+
table: Table
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/react/BlockRenderer.tsx
|
|
219
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
220
|
+
function defaultResolveContentLink(ref) {
|
|
221
|
+
if (!ref.published) return "#";
|
|
222
|
+
return `/${ref.collection}/${ref.slug}`;
|
|
223
|
+
}
|
|
224
|
+
function BlockRenderer({
|
|
225
|
+
blocks,
|
|
226
|
+
components,
|
|
227
|
+
cdnUrl,
|
|
228
|
+
refs,
|
|
229
|
+
resolveContentLink,
|
|
230
|
+
fallback,
|
|
231
|
+
className
|
|
232
|
+
}) {
|
|
233
|
+
const merged = { ...defaultBlockComponents, ...components };
|
|
234
|
+
const renderItems = groupListItems(blocks);
|
|
235
|
+
const FallbackComponent = fallback === null ? null : fallback ?? Fallback;
|
|
236
|
+
const resolve = resolveContentLink ?? defaultResolveContentLink;
|
|
237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className, children: renderItems.map((item, i) => {
|
|
238
|
+
if (item.listType) {
|
|
239
|
+
const ListComponent = merged[item.listType];
|
|
240
|
+
if (ListComponent) {
|
|
241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
242
|
+
ListComponent,
|
|
243
|
+
{
|
|
244
|
+
block: item.items[0],
|
|
245
|
+
items: item.items,
|
|
246
|
+
cdnUrl,
|
|
247
|
+
refs,
|
|
248
|
+
resolveContentLink: resolve,
|
|
249
|
+
components: merged
|
|
250
|
+
},
|
|
251
|
+
item.items[0].id
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
const block = item.block;
|
|
257
|
+
const Component = merged[block.type];
|
|
258
|
+
if (!Component) {
|
|
259
|
+
if (FallbackComponent) {
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
261
|
+
FallbackComponent,
|
|
262
|
+
{
|
|
263
|
+
block,
|
|
264
|
+
cdnUrl,
|
|
265
|
+
refs,
|
|
266
|
+
resolveContentLink: resolve,
|
|
267
|
+
components: merged
|
|
268
|
+
},
|
|
269
|
+
block.id
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
275
|
+
Component,
|
|
276
|
+
{
|
|
277
|
+
block,
|
|
278
|
+
cdnUrl,
|
|
279
|
+
refs,
|
|
280
|
+
resolveContentLink: resolve,
|
|
281
|
+
components: merged
|
|
282
|
+
},
|
|
283
|
+
block.id
|
|
284
|
+
);
|
|
285
|
+
}) });
|
|
286
|
+
}
|
|
287
|
+
var LIST_TYPE_MAP = {
|
|
288
|
+
bulletListItem: "bulletList",
|
|
289
|
+
numberedListItem: "numberedList",
|
|
290
|
+
checkListItem: "checkList"
|
|
291
|
+
};
|
|
292
|
+
function groupListItems(blocks) {
|
|
293
|
+
const result = [];
|
|
294
|
+
for (const block of blocks) {
|
|
295
|
+
const listType = LIST_TYPE_MAP[block.type];
|
|
296
|
+
if (listType) {
|
|
297
|
+
const last = result[result.length - 1];
|
|
298
|
+
if (last?.listType === listType) {
|
|
299
|
+
last.items.push(block);
|
|
300
|
+
} else {
|
|
301
|
+
result.push({ listType, items: [block] });
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
result.push({ block });
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
310
|
+
0 && (module.exports = {
|
|
311
|
+
BlockRenderer,
|
|
312
|
+
BulletList,
|
|
313
|
+
CheckList,
|
|
314
|
+
CodeBlock,
|
|
315
|
+
Fallback,
|
|
316
|
+
Heading,
|
|
317
|
+
ImageBlock,
|
|
318
|
+
InlineContent,
|
|
319
|
+
NumberedList,
|
|
320
|
+
Paragraph,
|
|
321
|
+
Table,
|
|
322
|
+
defaultBlockComponents
|
|
323
|
+
});
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
interface TextStyles {
|
|
5
|
+
bold?: boolean;
|
|
6
|
+
italic?: boolean;
|
|
7
|
+
underline?: boolean;
|
|
8
|
+
strikethrough?: boolean;
|
|
9
|
+
code?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface TextContent {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
styles?: TextStyles;
|
|
15
|
+
}
|
|
16
|
+
interface LinkContent {
|
|
17
|
+
type: "link";
|
|
18
|
+
href: string;
|
|
19
|
+
content: TextContent[];
|
|
20
|
+
}
|
|
21
|
+
type InlineContent$1 = TextContent | LinkContent;
|
|
22
|
+
interface TableRow {
|
|
23
|
+
cells: InlineContent$1[][];
|
|
24
|
+
}
|
|
25
|
+
interface TableContent {
|
|
26
|
+
type: "tableContent";
|
|
27
|
+
rows: TableRow[];
|
|
28
|
+
}
|
|
29
|
+
interface Block {
|
|
30
|
+
id: string;
|
|
31
|
+
type: string;
|
|
32
|
+
props?: Record<string, unknown> | null;
|
|
33
|
+
content?: InlineContent$1[] | TableContent;
|
|
34
|
+
children?: Block[];
|
|
35
|
+
}
|
|
36
|
+
/** A reference to another content item (used in relationships and _refs). */
|
|
37
|
+
interface ContentRef {
|
|
38
|
+
contentId: string;
|
|
39
|
+
collection: string;
|
|
40
|
+
slug: string;
|
|
41
|
+
title: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolved content reference in the public API `_refs` map.
|
|
45
|
+
* Includes `published` status so frontends can handle broken links.
|
|
46
|
+
*/
|
|
47
|
+
interface PublicContentRef extends ContentRef {
|
|
48
|
+
published: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Map of contentId → resolved reference metadata.
|
|
52
|
+
* Returned in `_refs` on single-content API responses.
|
|
53
|
+
* Used by block renderers to resolve `headroom://content/...` links.
|
|
54
|
+
*/
|
|
55
|
+
type RefsMap = Record<string, PublicContentRef>;
|
|
56
|
+
|
|
57
|
+
declare function Paragraph({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
declare function Heading({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
|
|
61
|
+
declare function ImageBlock({ block, cdnUrl }: BlockComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
62
|
+
|
|
63
|
+
declare function CodeBlock({ block }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
64
|
+
|
|
65
|
+
declare function BulletList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
66
|
+
|
|
67
|
+
declare function NumberedList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
|
|
69
|
+
declare function CheckList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
70
|
+
|
|
71
|
+
declare function Table({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
72
|
+
|
|
73
|
+
declare function Fallback({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
|
|
75
|
+
interface BlockComponentProps {
|
|
76
|
+
block: Block;
|
|
77
|
+
items?: Block[];
|
|
78
|
+
cdnUrl?: string;
|
|
79
|
+
refs?: RefsMap;
|
|
80
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
81
|
+
components?: BlockComponentMap;
|
|
82
|
+
}
|
|
83
|
+
type BlockComponentMap = Record<string, ComponentType<BlockComponentProps>>;
|
|
84
|
+
|
|
85
|
+
declare const defaultBlockComponents: BlockComponentMap;
|
|
86
|
+
|
|
87
|
+
interface BlockRendererProps {
|
|
88
|
+
blocks: Block[];
|
|
89
|
+
components?: BlockComponentMap;
|
|
90
|
+
cdnUrl?: string;
|
|
91
|
+
refs?: RefsMap;
|
|
92
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
93
|
+
fallback?: React.ComponentType<BlockComponentProps> | null;
|
|
94
|
+
className?: string;
|
|
95
|
+
}
|
|
96
|
+
declare function BlockRenderer({ blocks, components, cdnUrl, refs, resolveContentLink, fallback, className, }: BlockRendererProps): react_jsx_runtime.JSX.Element;
|
|
97
|
+
|
|
98
|
+
interface Props {
|
|
99
|
+
content: InlineContent$1[] | undefined | null;
|
|
100
|
+
refs?: RefsMap;
|
|
101
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
102
|
+
}
|
|
103
|
+
declare function InlineContent({ content, refs, resolveContentLink }: Props): react_jsx_runtime.JSX.Element | null;
|
|
104
|
+
|
|
105
|
+
export { type BlockComponentMap, type BlockComponentProps, BlockRenderer, type BlockRendererProps, BulletList, CheckList, CodeBlock, Fallback, Heading, ImageBlock, InlineContent, NumberedList, Paragraph, Table, defaultBlockComponents };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ComponentType } from 'react';
|
|
3
|
+
|
|
4
|
+
interface TextStyles {
|
|
5
|
+
bold?: boolean;
|
|
6
|
+
italic?: boolean;
|
|
7
|
+
underline?: boolean;
|
|
8
|
+
strikethrough?: boolean;
|
|
9
|
+
code?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface TextContent {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
styles?: TextStyles;
|
|
15
|
+
}
|
|
16
|
+
interface LinkContent {
|
|
17
|
+
type: "link";
|
|
18
|
+
href: string;
|
|
19
|
+
content: TextContent[];
|
|
20
|
+
}
|
|
21
|
+
type InlineContent$1 = TextContent | LinkContent;
|
|
22
|
+
interface TableRow {
|
|
23
|
+
cells: InlineContent$1[][];
|
|
24
|
+
}
|
|
25
|
+
interface TableContent {
|
|
26
|
+
type: "tableContent";
|
|
27
|
+
rows: TableRow[];
|
|
28
|
+
}
|
|
29
|
+
interface Block {
|
|
30
|
+
id: string;
|
|
31
|
+
type: string;
|
|
32
|
+
props?: Record<string, unknown> | null;
|
|
33
|
+
content?: InlineContent$1[] | TableContent;
|
|
34
|
+
children?: Block[];
|
|
35
|
+
}
|
|
36
|
+
/** A reference to another content item (used in relationships and _refs). */
|
|
37
|
+
interface ContentRef {
|
|
38
|
+
contentId: string;
|
|
39
|
+
collection: string;
|
|
40
|
+
slug: string;
|
|
41
|
+
title: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolved content reference in the public API `_refs` map.
|
|
45
|
+
* Includes `published` status so frontends can handle broken links.
|
|
46
|
+
*/
|
|
47
|
+
interface PublicContentRef extends ContentRef {
|
|
48
|
+
published: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Map of contentId → resolved reference metadata.
|
|
52
|
+
* Returned in `_refs` on single-content API responses.
|
|
53
|
+
* Used by block renderers to resolve `headroom://content/...` links.
|
|
54
|
+
*/
|
|
55
|
+
type RefsMap = Record<string, PublicContentRef>;
|
|
56
|
+
|
|
57
|
+
declare function Paragraph({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
declare function Heading({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
|
|
61
|
+
declare function ImageBlock({ block, cdnUrl }: BlockComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
62
|
+
|
|
63
|
+
declare function CodeBlock({ block }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
64
|
+
|
|
65
|
+
declare function BulletList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
66
|
+
|
|
67
|
+
declare function NumberedList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
|
|
69
|
+
declare function CheckList({ items, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
70
|
+
|
|
71
|
+
declare function Table({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
72
|
+
|
|
73
|
+
declare function Fallback({ block, refs, resolveContentLink }: BlockComponentProps): react_jsx_runtime.JSX.Element;
|
|
74
|
+
|
|
75
|
+
interface BlockComponentProps {
|
|
76
|
+
block: Block;
|
|
77
|
+
items?: Block[];
|
|
78
|
+
cdnUrl?: string;
|
|
79
|
+
refs?: RefsMap;
|
|
80
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
81
|
+
components?: BlockComponentMap;
|
|
82
|
+
}
|
|
83
|
+
type BlockComponentMap = Record<string, ComponentType<BlockComponentProps>>;
|
|
84
|
+
|
|
85
|
+
declare const defaultBlockComponents: BlockComponentMap;
|
|
86
|
+
|
|
87
|
+
interface BlockRendererProps {
|
|
88
|
+
blocks: Block[];
|
|
89
|
+
components?: BlockComponentMap;
|
|
90
|
+
cdnUrl?: string;
|
|
91
|
+
refs?: RefsMap;
|
|
92
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
93
|
+
fallback?: React.ComponentType<BlockComponentProps> | null;
|
|
94
|
+
className?: string;
|
|
95
|
+
}
|
|
96
|
+
declare function BlockRenderer({ blocks, components, cdnUrl, refs, resolveContentLink, fallback, className, }: BlockRendererProps): react_jsx_runtime.JSX.Element;
|
|
97
|
+
|
|
98
|
+
interface Props {
|
|
99
|
+
content: InlineContent$1[] | undefined | null;
|
|
100
|
+
refs?: RefsMap;
|
|
101
|
+
resolveContentLink?: (ref: PublicContentRef) => string;
|
|
102
|
+
}
|
|
103
|
+
declare function InlineContent({ content, refs, resolveContentLink }: Props): react_jsx_runtime.JSX.Element | null;
|
|
104
|
+
|
|
105
|
+
export { type BlockComponentMap, type BlockComponentProps, BlockRenderer, type BlockRendererProps, BulletList, CheckList, CodeBlock, Fallback, Heading, ImageBlock, InlineContent, NumberedList, Paragraph, Table, defaultBlockComponents };
|