reallysimpledocs 1.0.0-beta.4 → 1.0.0-beta.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/README.md +35 -35
- package/package.json +10 -13
- package/src/astro/index.js +46 -98
- package/src/astro/preview-source.js +90 -0
- package/src/components/index.js +1 -0
- package/src/css/custom.css +252 -33
- package/src/css/styles/luma.css +11 -0
- package/src/css/styles/lyra.css +11 -0
- package/src/css/styles/maia.css +11 -0
- package/src/css/styles/mira.css +11 -0
- package/src/css/styles/nova.css +11 -0
- package/src/css/styles/rhea.css +11 -0
- package/src/css/styles/sera.css +11 -0
- package/src/css/styles/vega.css +11 -0
- package/src/runtime/components/BaseLayout.astro +20 -27
- package/src/runtime/components/CommandDialog.astro +30 -32
- package/src/runtime/components/DefaultContentHeader.astro +0 -17
- package/src/runtime/components/DefaultHead.astro +120 -0
- package/src/runtime/components/DefaultHeadContent.astro +2 -0
- package/src/runtime/components/DefaultSidebarHeader.astro +1 -1
- package/src/runtime/components/DocsLayout.astro +114 -165
- package/src/runtime/components/DropdownMenu.astro +1 -1
- package/src/runtime/components/ThemeToggle.astro +21 -0
- package/src/runtime/components/mdx/Callout.astro +2 -32
- package/src/runtime/components/mdx/Card.astro +3 -8
- package/src/runtime/components/mdx/CardGrid.astro +1 -1
- package/src/runtime/components/mdx/Code.astro +2 -16
- package/src/runtime/components/mdx/CodeGroup.astro +7 -11
- package/src/runtime/components/mdx/Preview.astro +7 -13
- package/src/runtime/components/mdx/Steps.astro +1 -5
- package/src/runtime/components/mdx/Tab.astro +6 -0
- package/src/runtime/components/mdx/Tabs.astro +7 -7
- package/src/runtime/lib/docs.js +130 -102
- package/src/runtime/lib/highlight.js +1 -14
- package/src/runtime/lib/macros.js +10 -5
- package/src/runtime/lib/markdown-export.js +134 -171
- package/src/runtime/pages/doc.astro +1 -3
- package/src/runtime/pages/llms-full.txt.ts +2 -2
- package/src/runtime/pages/llms.txt.ts +2 -2
- package/src/runtime/pages/markdown.ts +2 -2
- package/src/runtime/pages/search-index.ts +12 -3
- package/CHANGELOG.md +0 -35
- package/src/css/overrides.css +0 -1
- package/src/css/sources.css +0 -1
- package/src/runtime/lib/markdown-exporters/index.js +0 -144
- package/src/runtime/lib/mdx-source.js +0 -19
- package/src/runtime/lib/preview-source-plugin.js +0 -33
- package/src/runtime/scripts/copy-code.js +0 -130
- package/src/site/ContentHeader.astro +0 -33
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getMdxChildrenSource } from "./mdx-source.js";
|
|
2
|
-
|
|
3
|
-
export function previewSourceRemarkPlugin() {
|
|
4
|
-
return (tree, file) => {
|
|
5
|
-
const source = String(file.value || "");
|
|
6
|
-
walk(tree, (node) => {
|
|
7
|
-
if (!isPreview(node) || hasAttribute(node, "code")) return;
|
|
8
|
-
const code = getMdxChildrenSource(node, source);
|
|
9
|
-
node.attributes = [
|
|
10
|
-
...(node.attributes || []),
|
|
11
|
-
{
|
|
12
|
-
type: "mdxJsxAttribute",
|
|
13
|
-
name: "code",
|
|
14
|
-
value: code,
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function walk(node, callback) {
|
|
22
|
-
if (!node || typeof node !== "object") return;
|
|
23
|
-
callback(node);
|
|
24
|
-
for (const child of node.children || []) walk(child, callback);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isPreview(node) {
|
|
28
|
-
return node?.type === "mdxJsxFlowElement" && node.name === "Preview";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function hasAttribute(node, name) {
|
|
32
|
-
return (node.attributes || []).some((attr) => attr.type === "mdxJsxAttribute" && attr.name === name);
|
|
33
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import Copy from "lucide-static/icons/copy.svg?raw";
|
|
2
|
-
import Check from "lucide-static/icons/check.svg?raw";
|
|
3
|
-
|
|
4
|
-
const copyText = async (text) => {
|
|
5
|
-
if (window.isSecureContext && navigator.clipboard?.writeText) {
|
|
6
|
-
return navigator.clipboard.writeText(text);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const textarea = document.createElement("textarea");
|
|
10
|
-
textarea.value = text;
|
|
11
|
-
textarea.setAttribute("readonly", "");
|
|
12
|
-
textarea.style.position = "fixed";
|
|
13
|
-
textarea.style.top = "-9999px";
|
|
14
|
-
textarea.style.left = "-9999px";
|
|
15
|
-
document.body.appendChild(textarea);
|
|
16
|
-
textarea.select();
|
|
17
|
-
const ok = document.execCommand("copy");
|
|
18
|
-
textarea.remove();
|
|
19
|
-
if (!ok) throw new Error("Copy failed");
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const activePanelCode = (root) =>
|
|
23
|
-
root.querySelector(':scope > [role="tabpanel"]:not([hidden]) code');
|
|
24
|
-
const codeFrameClass =
|
|
25
|
-
"relative my-6 w-full max-w-full overflow-hidden rounded-lg";
|
|
26
|
-
const codePreClasses = [
|
|
27
|
-
"!my-0",
|
|
28
|
-
"max-w-full",
|
|
29
|
-
"overflow-x-auto",
|
|
30
|
-
"!rounded-none",
|
|
31
|
-
"!border-0",
|
|
32
|
-
];
|
|
33
|
-
const codeContentClasses = [
|
|
34
|
-
"block",
|
|
35
|
-
"min-w-full",
|
|
36
|
-
"w-max",
|
|
37
|
-
"px-4",
|
|
38
|
-
"py-3",
|
|
39
|
-
"text-[13px]",
|
|
40
|
-
];
|
|
41
|
-
const copyButtonClass =
|
|
42
|
-
"flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 dark:hover:bg-accent/50 [&_svg]:size-4";
|
|
43
|
-
|
|
44
|
-
const initCopyCode = (codeBlock) => {
|
|
45
|
-
const codeEl = codeBlock.querySelector(":scope > code");
|
|
46
|
-
if (!codeEl) return;
|
|
47
|
-
|
|
48
|
-
codeBlock.classList.add(...codePreClasses);
|
|
49
|
-
codeEl.classList.add(...codeContentClasses);
|
|
50
|
-
|
|
51
|
-
let target = null;
|
|
52
|
-
let frame = codeBlock.closest("[data-code-group]");
|
|
53
|
-
let getCode = frame ? () => activePanelCode(frame) || codeEl : () => codeEl;
|
|
54
|
-
if (frame) target = frame.querySelector(":scope > header");
|
|
55
|
-
|
|
56
|
-
const preview = codeBlock.closest("[data-preview]");
|
|
57
|
-
const previewCodePanel = preview?.querySelector(":scope > [data-code-panel]");
|
|
58
|
-
if (!frame && previewCodePanel?.contains(codeBlock)) {
|
|
59
|
-
frame = preview;
|
|
60
|
-
target = frame.querySelector(":scope > header");
|
|
61
|
-
getCode = () => codeEl;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!frame) {
|
|
65
|
-
frame = codeBlock.parentElement?.hasAttribute("data-code-block")
|
|
66
|
-
? codeBlock.parentElement
|
|
67
|
-
: null;
|
|
68
|
-
if (!frame) {
|
|
69
|
-
frame = document.createElement("div");
|
|
70
|
-
frame.dataset.codeBlock = "";
|
|
71
|
-
frame.className = codeFrameClass;
|
|
72
|
-
codeBlock.parentNode.insertBefore(frame, codeBlock);
|
|
73
|
-
frame.appendChild(codeBlock);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
target ||= frame.querySelector(":scope > header") || frame;
|
|
78
|
-
|
|
79
|
-
if (target.querySelector(":scope > button[aria-label='Copy code']")) {
|
|
80
|
-
codeBlock.dataset.copyCodeInitialized = true;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const button = document.createElement("button");
|
|
85
|
-
button.type = "button";
|
|
86
|
-
button.setAttribute("aria-label", "Copy code");
|
|
87
|
-
button.className = `${copyButtonClass} ${
|
|
88
|
-
target === frame
|
|
89
|
-
? "absolute right-2.5 top-2.5 bg-muted/50 backdrop-blur-sm"
|
|
90
|
-
: "ml-auto"
|
|
91
|
-
}`;
|
|
92
|
-
button.innerHTML = Copy;
|
|
93
|
-
|
|
94
|
-
button.addEventListener("click", async () => {
|
|
95
|
-
const text = (getCode()?.textContent || "").replace(/\n$/, "");
|
|
96
|
-
if (!text) return;
|
|
97
|
-
|
|
98
|
-
button.disabled = true;
|
|
99
|
-
try {
|
|
100
|
-
await copyText(text);
|
|
101
|
-
button.innerHTML = Check;
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.error("[copy] Failed to copy:", error);
|
|
104
|
-
button.textContent = "Failed";
|
|
105
|
-
}
|
|
106
|
-
window.setTimeout(() => {
|
|
107
|
-
button.disabled = false;
|
|
108
|
-
button.innerHTML = Copy;
|
|
109
|
-
}, 1200);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
target.appendChild(button);
|
|
113
|
-
if (previewCodePanel?.contains(codeBlock)) {
|
|
114
|
-
const syncPreviewCopyButton = () => {
|
|
115
|
-
button.hidden = previewCodePanel.hidden;
|
|
116
|
-
};
|
|
117
|
-
syncPreviewCopyButton();
|
|
118
|
-
new MutationObserver(syncPreviewCopyButton).observe(previewCodePanel, {
|
|
119
|
-
attributes: true,
|
|
120
|
-
attributeFilter: ["hidden"],
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
codeBlock.dataset.copyCodeInitialized = true;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
window.basecoat?.register(
|
|
127
|
-
"copy-code",
|
|
128
|
-
"pre:has(> code):not([data-copy-code-initialized])",
|
|
129
|
-
initCopyCode,
|
|
130
|
-
);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import Moon from "lucide-static/icons/moon.svg?raw";
|
|
3
|
-
import Sun from "lucide-static/icons/sun.svg?raw";
|
|
4
|
-
|
|
5
|
-
const github = `<svg role="img" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>`;
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<nav class="hidden items-center gap-2 sm:flex">
|
|
9
|
-
<a
|
|
10
|
-
class="btn-sm"
|
|
11
|
-
href="https://github.com/hunvreus/reallysimpledocs"
|
|
12
|
-
target="_blank"
|
|
13
|
-
rel="noopener"
|
|
14
|
-
aria-label="GitHub"
|
|
15
|
-
data-tooltip="GitHub"
|
|
16
|
-
data-side="bottom"
|
|
17
|
-
>
|
|
18
|
-
<Fragment set:html={github} />
|
|
19
|
-
GitHub
|
|
20
|
-
</a>
|
|
21
|
-
<button
|
|
22
|
-
type="button"
|
|
23
|
-
aria-label="Toggle dark mode"
|
|
24
|
-
data-tooltip="Toggle dark mode"
|
|
25
|
-
data-side="bottom"
|
|
26
|
-
data-align="end"
|
|
27
|
-
onclick="document.dispatchEvent(new CustomEvent('basecoat:theme'))"
|
|
28
|
-
class="btn-sm-icon-ghost"
|
|
29
|
-
>
|
|
30
|
-
<span class="hidden dark:block"><Fragment set:html={Sun} /></span>
|
|
31
|
-
<span class="block dark:hidden"><Fragment set:html={Moon} /></span>
|
|
32
|
-
</button>
|
|
33
|
-
</nav>
|