reallysimpledocs 1.0.4 → 1.0.5
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/package.json
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import * as lucideIcons from "lucide-static";
|
|
3
3
|
import { addSvgClass } from "../../lib/html.js";
|
|
4
4
|
|
|
5
|
-
const { type, title = "Note", icon: iconName, class: className = "" } = Astro.props;
|
|
5
|
+
const { type, title = "Note", icon: iconName, action, class: className = "" } = Astro.props;
|
|
6
6
|
const normalizedType = String(type || "").toLowerCase();
|
|
7
7
|
const calloutType = normalizedType === "warning" || normalizedType === "destructive" ? normalizedType : "";
|
|
8
|
+
const actionLabel = typeof action?.label === "string" ? action.label.trim() : "";
|
|
9
|
+
const actionHref = typeof action?.href === "string" ? action.href.trim() : "";
|
|
8
10
|
|
|
9
11
|
function resolveNamedIcon(name) {
|
|
10
12
|
if (!name || typeof name !== "string") return "";
|
|
@@ -31,4 +33,13 @@ const heading = title;
|
|
|
31
33
|
<section>
|
|
32
34
|
<slot />
|
|
33
35
|
</section>
|
|
36
|
+
{
|
|
37
|
+
actionLabel && actionHref && (
|
|
38
|
+
<footer>
|
|
39
|
+
<a class="btn" data-variant="outline" data-size="sm" href={actionHref}>
|
|
40
|
+
{actionLabel}
|
|
41
|
+
</a>
|
|
42
|
+
</footer>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
34
45
|
</div>
|
|
@@ -94,12 +94,14 @@ function serializePreview(attrs, children, context = new Map()) {
|
|
|
94
94
|
|
|
95
95
|
function serializeCallout(attrs, children, context = new Map()) {
|
|
96
96
|
const title = getStringAttr(attrs, "title") || calloutTitle(getStringAttr(attrs, "type"));
|
|
97
|
+
const action = getObjectAttr(attrs, "action");
|
|
97
98
|
const body = normalizeMdxComponents(children, context)
|
|
98
99
|
.trim()
|
|
99
100
|
.split("\n")
|
|
100
101
|
.map((line) => `> ${line}`)
|
|
101
102
|
.join("\n");
|
|
102
|
-
|
|
103
|
+
const footer = action?.label && action?.href ? `> [${action.label}](${action.href})\n` : "";
|
|
104
|
+
return `\n\n> **${title}**\n${body ? `${body}\n` : ""}${footer}`;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
function serializeSteps(_attrs, children, context = new Map()) {
|
|
@@ -137,6 +139,14 @@ function getExpressionAttr(attrs, name) {
|
|
|
137
139
|
return String(attrs || "").match(new RegExp(`${name}=\\{([A-Za-z_$][\\w$]*)\\}`))?.[1] || "";
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
function getObjectAttr(attrs, name) {
|
|
143
|
+
const value = String(attrs || "").match(new RegExp(`${name}=\\{\\{([\\s\\S]*?)\\}\\}`))?.[1] || "";
|
|
144
|
+
if (!value) return null;
|
|
145
|
+
return Object.fromEntries(
|
|
146
|
+
[...value.matchAll(/([A-Za-z_$][\w$]*)\s*:\s*["']([^"']*)["']/g)].map(([, key, item]) => [key, item]),
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
140
150
|
function getCodeAttr(attrs, context = new Map()) {
|
|
141
151
|
const direct = String(attrs || "").match(/\bcode=\{`([\s\S]*?)`\}/)?.[1] || "";
|
|
142
152
|
if (direct) return direct.replace(/\\n/g, "\n").replace(/\\`/g, "`");
|