reallysimpledocs 1.0.0-beta.3 → 1.0.0-beta.4
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/CHANGELOG.md +35 -0
- package/README.md +10 -8
- package/package.json +10 -2
- package/src/astro/index.js +56 -1
- package/src/css/custom.css +35 -24
- package/src/runtime/components/CommandDialog.astro +19 -2
- package/src/runtime/components/DefaultContentHeader.astro +19 -0
- package/src/runtime/components/DefaultSidebarFooter.astro +2 -0
- package/src/runtime/components/DocsLayout.astro +100 -81
- package/src/runtime/components/Sidebar.astro +4 -0
- package/src/runtime/components/mdx/Callout.astro +28 -5
- package/src/runtime/components/mdx/Preview.astro +2 -1
- package/src/runtime/lib/docs.js +92 -14
- package/src/runtime/lib/macros.js +5 -1
- package/src/runtime/lib/markdown-export.js +200 -0
- package/src/runtime/lib/markdown-exporters/index.js +144 -0
- package/src/runtime/lib/mdx-source.js +19 -0
- package/src/runtime/lib/preview-source-plugin.js +33 -0
- package/src/runtime/lib/site.js +0 -1
- package/src/runtime/pages/doc.astro +3 -1
- 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 +2 -2
- package/src/runtime/scripts/copy-code.js +28 -7
- package/src/site/ContentHeader.astro +33 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import config from "virtual:reallysimpledocs/config";
|
|
3
|
+
import UserMdxComponents from "virtual:reallysimpledocs/mdx-components";
|
|
3
4
|
import { getMdxPage } from "virtual:reallysimpledocs/mdx-pages";
|
|
4
5
|
import * as RsdComponents from "../../components/index.js";
|
|
5
6
|
import DocsLayout from "../components/DocsLayout.astro";
|
|
@@ -18,8 +19,9 @@ const isMdx = page.extension === ".mdx";
|
|
|
18
19
|
const mdxModule = isMdx ? await getMdxPage(page.slug) : null;
|
|
19
20
|
const MdxContent = mdxModule?.Content || mdxModule?.default;
|
|
20
21
|
const doc = isMdx ? { page, headings: getDocHeadings(config, page), html: "" } : await renderDoc(config, page);
|
|
22
|
+
const mdxComponents = { ...RsdComponents, ...UserMdxComponents };
|
|
21
23
|
---
|
|
22
24
|
|
|
23
25
|
<DocsLayout page={page} headings={doc.headings}>
|
|
24
|
-
{MdxContent ? <MdxContent components={
|
|
26
|
+
{MdxContent ? <MdxContent components={mdxComponents} /> : <Fragment set:html={doc.html} />}
|
|
25
27
|
</DocsLayout>
|
|
@@ -2,12 +2,12 @@ import config from "virtual:reallysimpledocs/config";
|
|
|
2
2
|
import { getLlmDocs } from "../lib/docs.js";
|
|
3
3
|
import { getSite } from "../lib/site.js";
|
|
4
4
|
|
|
5
|
-
export function GET({ site }) {
|
|
5
|
+
export async function GET({ site }) {
|
|
6
6
|
const siteData = getSite(config);
|
|
7
7
|
const siteUrl = site?.toString().replace(/\/$/, "") || siteData.url || "";
|
|
8
8
|
const lines = [];
|
|
9
9
|
|
|
10
|
-
getLlmDocs(config).forEach((doc) => {
|
|
10
|
+
(await getLlmDocs(config)).forEach((doc) => {
|
|
11
11
|
lines.push(`# ${doc.title}`, `Source: ${siteUrl}${doc.path}`, "");
|
|
12
12
|
lines.push(doc.content, "", "---", "");
|
|
13
13
|
});
|
|
@@ -2,9 +2,9 @@ import config from "virtual:reallysimpledocs/config";
|
|
|
2
2
|
import { flattenMenuSlugs, getLlmDocs, getManifest } from "../lib/docs.js";
|
|
3
3
|
import { getSite } from "../lib/site.js";
|
|
4
4
|
|
|
5
|
-
export function GET({ site }) {
|
|
5
|
+
export async function GET({ site }) {
|
|
6
6
|
const manifest = getManifest(config);
|
|
7
|
-
const docs = getLlmDocs(config);
|
|
7
|
+
const docs = await getLlmDocs(config);
|
|
8
8
|
const bySlug = new Map(docs.map((doc) => [doc.slug, doc]));
|
|
9
9
|
const siteData = getSite(config);
|
|
10
10
|
const siteUrl = site?.toString().replace(/\/$/, "") || siteData.url || "";
|
|
@@ -8,8 +8,8 @@ export function getStaticPaths() {
|
|
|
8
8
|
}));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function GET({ props }) {
|
|
12
|
-
return new Response(getMarkdownExport(config, props.page), {
|
|
11
|
+
export async function GET({ props }) {
|
|
12
|
+
return new Response(await getMarkdownExport(config, props.page), {
|
|
13
13
|
headers: {
|
|
14
14
|
"content-type": "text/markdown; charset=utf-8",
|
|
15
15
|
},
|
|
@@ -2,8 +2,8 @@ import lunr from "lunr";
|
|
|
2
2
|
import config from "virtual:reallysimpledocs/config";
|
|
3
3
|
import { getSearchDocs } from "../lib/docs.js";
|
|
4
4
|
|
|
5
|
-
export function GET() {
|
|
6
|
-
const documents = getSearchDocs(config);
|
|
5
|
+
export async function GET() {
|
|
6
|
+
const documents = await getSearchDocs(config);
|
|
7
7
|
const index = lunr(function () {
|
|
8
8
|
this.ref("slug");
|
|
9
9
|
this.field("title", { boost: 10 });
|
|
@@ -19,10 +19,25 @@ const copyText = async (text) => {
|
|
|
19
19
|
if (!ok) throw new Error("Copy failed");
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const activePanelCode = (root) =>
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
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
|
+
];
|
|
26
41
|
const copyButtonClass =
|
|
27
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";
|
|
28
43
|
|
|
@@ -47,7 +62,9 @@ const initCopyCode = (codeBlock) => {
|
|
|
47
62
|
}
|
|
48
63
|
|
|
49
64
|
if (!frame) {
|
|
50
|
-
frame = codeBlock.parentElement?.hasAttribute("data-code-block")
|
|
65
|
+
frame = codeBlock.parentElement?.hasAttribute("data-code-block")
|
|
66
|
+
? codeBlock.parentElement
|
|
67
|
+
: null;
|
|
51
68
|
if (!frame) {
|
|
52
69
|
frame = document.createElement("div");
|
|
53
70
|
frame.dataset.codeBlock = "";
|
|
@@ -69,7 +86,7 @@ const initCopyCode = (codeBlock) => {
|
|
|
69
86
|
button.setAttribute("aria-label", "Copy code");
|
|
70
87
|
button.className = `${copyButtonClass} ${
|
|
71
88
|
target === frame
|
|
72
|
-
? "absolute right-2.5 top-2.5 bg-muted/50
|
|
89
|
+
? "absolute right-2.5 top-2.5 bg-muted/50 backdrop-blur-sm"
|
|
73
90
|
: "ml-auto"
|
|
74
91
|
}`;
|
|
75
92
|
button.innerHTML = Copy;
|
|
@@ -106,4 +123,8 @@ const initCopyCode = (codeBlock) => {
|
|
|
106
123
|
codeBlock.dataset.copyCodeInitialized = true;
|
|
107
124
|
};
|
|
108
125
|
|
|
109
|
-
window.basecoat?.register(
|
|
126
|
+
window.basecoat?.register(
|
|
127
|
+
"copy-code",
|
|
128
|
+
"pre:has(> code):not([data-copy-code-initialized])",
|
|
129
|
+
initCopyCode,
|
|
130
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
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>
|