reallysimpledocs 1.0.4 → 1.0.6
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 -0
- package/package.json +3 -2
- package/src/astro/rehype-basecoat-tables.js +6 -0
- package/src/css/custom.css +3 -1
- package/src/runtime/components/BaseLayout.astro +3 -3
- package/src/runtime/components/mdx/Callout.astro +12 -1
- package/src/runtime/lib/docs.js +6 -1
- package/src/runtime/lib/markdown-export.js +11 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reallysimpledocs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"build": "rm -rf dist && astro build",
|
|
21
21
|
"preview": "astro preview",
|
|
22
22
|
"smoke:consumer": "node scripts/smoke-consumer.mjs",
|
|
23
|
-
"check": "npm run build && npm pack --dry-run && npm run smoke:consumer"
|
|
23
|
+
"check": "npm run build && node scripts/assert-site-output.mjs && npm pack --dry-run && npm run smoke:consumer"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@astrojs/markdown-remark": "^7.2.0",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"tailwindcss": ">=4.1.17 <5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@astrojs/sitemap": "^3.6.0",
|
|
44
45
|
"astro": "^6.4.6",
|
|
45
46
|
"basecoat-css": "^1.0.0-beta.6",
|
|
46
47
|
"htmx.org": "^2.0.10",
|
|
@@ -65,6 +65,7 @@ function addHeadingAnchor(node, slugger) {
|
|
|
65
65
|
if (!id) return;
|
|
66
66
|
node.properties.id = id;
|
|
67
67
|
node.properties.tabIndex ??= -1;
|
|
68
|
+
if (hasElement(node, "a")) return;
|
|
68
69
|
node.children = [
|
|
69
70
|
{
|
|
70
71
|
type: "element",
|
|
@@ -97,6 +98,11 @@ function nodeText(node) {
|
|
|
97
98
|
return node.children.map(nodeText).join("");
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
function hasElement(node, tagName) {
|
|
102
|
+
if (isElement(node, tagName)) return true;
|
|
103
|
+
return Array.isArray(node?.children) && node.children.some((child) => hasElement(child, tagName));
|
|
104
|
+
}
|
|
105
|
+
|
|
100
106
|
function isElement(node, tagName) {
|
|
101
107
|
return node?.type === "element" && node.tagName === tagName;
|
|
102
108
|
}
|
package/src/css/custom.css
CHANGED
|
@@ -11,9 +11,9 @@ const metaTitle = pagePath === "/" ? `${site.title} | ${metaDescription}` : `${t
|
|
|
11
11
|
const siteUrl = Astro.site?.toString().replace(/\/$/, "") || site.url || "";
|
|
12
12
|
const absoluteUrl = `${siteUrl}${pagePath}`;
|
|
13
13
|
const assetsBase = config.assetsBase || "/assets";
|
|
14
|
-
const favicon = site.
|
|
15
|
-
const appleTouchIcon = site.
|
|
16
|
-
const socialImage = site.
|
|
14
|
+
const favicon = site.favicon || "";
|
|
15
|
+
const appleTouchIcon = site.appleTouchIcon || "";
|
|
16
|
+
const socialImage = site.socialImage || "";
|
|
17
17
|
const assetPath = (value) => {
|
|
18
18
|
const path = String(value || "");
|
|
19
19
|
if (!path || path.startsWith("http") || path.startsWith("/")) return path;
|
|
@@ -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>
|
package/src/runtime/lib/docs.js
CHANGED
|
@@ -102,7 +102,8 @@ export async function renderDoc(config, page) {
|
|
|
102
102
|
const headingText = plainText(tokens);
|
|
103
103
|
const id = slugger.slug(headingText);
|
|
104
104
|
if (depth > 1 && depth < 4) headings.push({ depth, id, text: headingText });
|
|
105
|
-
|
|
105
|
+
const content = hasTokenType(tokens, "link") ? text : `<a class="header-anchor" href="#${id}">${text}</a>`;
|
|
106
|
+
return `<h${depth} id="${id}" tabindex="-1">${content}</h${depth}>`;
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
const tokens = marked.lexer(content);
|
|
@@ -432,6 +433,10 @@ function plainText(tokens) {
|
|
|
432
433
|
.join("");
|
|
433
434
|
}
|
|
434
435
|
|
|
436
|
+
function hasTokenType(tokens, type) {
|
|
437
|
+
return tokens.some((token) => token.type === type || (token.tokens && hasTokenType(token.tokens, type)));
|
|
438
|
+
}
|
|
439
|
+
|
|
435
440
|
function tokensText(tokens) {
|
|
436
441
|
return tokens
|
|
437
442
|
.map((token) => {
|
|
@@ -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, "`");
|