@the-smithy/hearth 0.14.0 → 0.15.0
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/dist/react.d.ts +14 -1
- package/dist/react.js +17 -6
- package/package.json +2 -2
package/dist/react.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ type GuideTheme = {
|
|
|
30
30
|
media?: string;
|
|
31
31
|
/** The "+" on an expandable question. */
|
|
32
32
|
accent?: string;
|
|
33
|
+
/** A step's label ("Step 1": the text-and-image block's eyebrow). */
|
|
34
|
+
eyebrow?: string;
|
|
35
|
+
/** A step's screenshot (the text-and-image block's image, shown full width under the step). */
|
|
36
|
+
screenshot?: string;
|
|
33
37
|
};
|
|
34
38
|
type GuideLinkProps = {
|
|
35
39
|
href: string;
|
|
@@ -47,6 +51,15 @@ type GuideBlocksProps = {
|
|
|
47
51
|
};
|
|
48
52
|
/** Block types a guide can use; anything else is skipped. */
|
|
49
53
|
declare const GUIDE_BLOCK_TYPES: readonly ["hero", "richText", "mediaText", "schedule", "cardGrid", "faq", "gallery", "video", "quote", "stats", "cta"];
|
|
54
|
+
/**
|
|
55
|
+
* The guide's sections that have a heading, in order, with the anchor each one gets: for an "In this guide" list.
|
|
56
|
+
*
|
|
57
|
+
* guideOutline(page.blocks).map((s) => <a href={`#${s.id}`}>{s.title}</a>)
|
|
58
|
+
*/
|
|
59
|
+
declare function guideOutline(blocks: readonly unknown[]): {
|
|
60
|
+
id: string;
|
|
61
|
+
title: string;
|
|
62
|
+
}[];
|
|
50
63
|
/**
|
|
51
64
|
* Render a guide's blocks with your product's styles.
|
|
52
65
|
*
|
|
@@ -95,4 +108,4 @@ declare function HearthEmbed({ block, className }: {
|
|
|
95
108
|
className?: string;
|
|
96
109
|
}): react.JSX.Element;
|
|
97
110
|
|
|
98
|
-
export { type BlockComponents, GUIDE_BLOCK_TYPES, GuideBlocks, type GuideBlocksProps, type GuideLinkProps, type GuideTheme, HearthBlocks, HearthEmbed, JsonLd };
|
|
111
|
+
export { type BlockComponents, GUIDE_BLOCK_TYPES, GuideBlocks, type GuideBlocksProps, type GuideLinkProps, type GuideTheme, HearthBlocks, HearthEmbed, JsonLd, guideOutline };
|
package/dist/react.js
CHANGED
|
@@ -6,6 +6,14 @@ import { EMBED_ALLOW, EMBED_SANDBOX, embedDocument } from "@the-smithy/hearth-sc
|
|
|
6
6
|
import { videoEmbedUrl } from "@the-smithy/hearth-schema";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
var GUIDE_BLOCK_TYPES = ["hero", "richText", "mediaText", "schedule", "cardGrid", "faq", "gallery", "video", "quote", "stats", "cta"];
|
|
9
|
+
var anchor = (text) => text.toLowerCase().replace(/\*/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
10
|
+
var headingOf = (b) => typeof b.data?.heading === "string" && b.data.heading.trim() ? b.data.heading.trim() : null;
|
|
11
|
+
function guideOutline(blocks) {
|
|
12
|
+
return blocks.flatMap((b) => {
|
|
13
|
+
const title = GUIDE_BLOCK_TYPES.includes(b.type) && b.type !== "cta" ? headingOf(b) : null;
|
|
14
|
+
return title ? [{ id: anchor(title), title: title.replace(/\*/g, "") }] : [];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
9
17
|
var stack = (gap) => ({ display: "flex", flexDirection: "column", gap });
|
|
10
18
|
var grid = (min) => ({ display: "grid", gap: "0.75rem", gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, ${min}), 1fr))` });
|
|
11
19
|
var fill = { display: "block", width: "100%", height: "auto" };
|
|
@@ -32,13 +40,14 @@ function GuideBlocks({ blocks, theme = {}, renderMarkdown = plainMarkdown, linkC
|
|
|
32
40
|
return md(d.markdown);
|
|
33
41
|
case "mediaText": {
|
|
34
42
|
const image = d.image;
|
|
35
|
-
return /* @__PURE__ */ jsxs("div", { style:
|
|
36
|
-
/* @__PURE__ */ jsxs("div", { style:
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { style: stack("0.75rem"), children: [
|
|
44
|
+
/* @__PURE__ */ jsxs("div", { style: stack("0.375rem"), children: [
|
|
45
|
+
str(d.eyebrow) ? /* @__PURE__ */ jsx("p", { className: t.eyebrow, children: str(d.eyebrow) }) : null,
|
|
37
46
|
heading(d.heading),
|
|
38
|
-
md(d.markdown),
|
|
47
|
+
str(d.markdown) ? md(d.markdown) : null,
|
|
39
48
|
d.cta ? /* @__PURE__ */ jsx("p", { children: link(d.cta) }) : null
|
|
40
49
|
] }),
|
|
41
|
-
image ? /* @__PURE__ */ jsx("figure", { style: { margin: 0
|
|
50
|
+
image ? /* @__PURE__ */ jsx("figure", { style: { margin: 0 }, children: img(image, t.screenshot ?? t.media) }) : null
|
|
42
51
|
] });
|
|
43
52
|
}
|
|
44
53
|
case "schedule": {
|
|
@@ -131,7 +140,8 @@ function GuideBlocks({ blocks, theme = {}, renderMarkdown = plainMarkdown, linkC
|
|
|
131
140
|
}
|
|
132
141
|
return /* @__PURE__ */ jsx("div", { className: t.root, style: t.root ? void 0 : stack("2rem"), children: blocks.map((b, i) => {
|
|
133
142
|
const out = render(b);
|
|
134
|
-
|
|
143
|
+
const title = b.type !== "cta" ? headingOf(b) : null;
|
|
144
|
+
return out ? /* @__PURE__ */ jsx("section", { id: title ? anchor(title) : void 0, style: title ? { scrollMarginTop: "1.5rem" } : void 0, children: out }, b.id ?? i) : null;
|
|
135
145
|
}) });
|
|
136
146
|
}
|
|
137
147
|
|
|
@@ -175,5 +185,6 @@ export {
|
|
|
175
185
|
GuideBlocks,
|
|
176
186
|
HearthBlocks,
|
|
177
187
|
HearthEmbed,
|
|
178
|
-
JsonLd
|
|
188
|
+
JsonLd,
|
|
189
|
+
guideOutline
|
|
179
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-smithy/hearth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Typed client for the Hearth Delivery API: content, SEO, forms and publish webhooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"llms.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@the-smithy/hearth-schema": "^0.
|
|
48
|
+
"@the-smithy/hearth-schema": "^0.15.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"next": ">=15",
|