radiant-docs 0.1.7 → 0.1.8
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/index.js +28 -5
- package/package.json +3 -3
- package/template/astro.config.mjs +76 -3
- package/template/package-lock.json +924 -737
- package/template/package.json +7 -5
- package/template/scripts/generate-og-images.mjs +335 -0
- package/template/scripts/generate-og-metadata.mjs +173 -0
- package/template/scripts/rewrite-static-asset-host.mjs +408 -0
- package/template/scripts/stamp-image-versions.mjs +277 -0
- package/template/scripts/stamp-og-image-versions.mjs +199 -0
- package/template/scripts/stamp-pagefind-runtime-version.mjs +140 -0
- package/template/src/assets/fonts/geist-mono/cyrillic.woff2 +0 -0
- package/template/src/assets/fonts/geist-mono/latin-ext.woff2 +0 -0
- package/template/src/assets/fonts/geist-mono/latin.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/canadian-aboriginal.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/cherokee.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/latin-ext.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/latin.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/math.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/nushu.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/symbols.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/syriac.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/tifinagh.woff2 +0 -0
- package/template/src/assets/fonts/google-sans-flex/vietnamese.woff2 +0 -0
- package/template/src/components/Footer.astro +94 -0
- package/template/src/components/Header.astro +11 -66
- package/template/src/components/LogoLink.astro +103 -0
- package/template/src/components/MdxPage.astro +126 -11
- package/template/src/components/OpenApiPage.astro +1036 -69
- package/template/src/components/Search.astro +0 -2
- package/template/src/components/SidebarDropdown.astro +34 -14
- package/template/src/components/SidebarGroup.astro +3 -6
- package/template/src/components/SidebarLink.astro +22 -12
- package/template/src/components/SidebarMenu.astro +19 -16
- package/template/src/components/SidebarSegmented.astro +99 -0
- package/template/src/components/SidebarSubgroup.astro +12 -12
- package/template/src/components/ThemeSwitcher.astro +30 -7
- package/template/src/components/endpoint/PlaygroundBar.astro +32 -36
- package/template/src/components/endpoint/PlaygroundButton.astro +40 -4
- package/template/src/components/endpoint/PlaygroundField.astro +1068 -22
- package/template/src/components/endpoint/PlaygroundForm.astro +559 -61
- package/template/src/components/endpoint/RequestSnippets.astro +342 -193
- package/template/src/components/endpoint/ResponseDisplay.astro +161 -147
- package/template/src/components/endpoint/ResponseFieldTree.astro +134 -0
- package/template/src/components/endpoint/ResponseFields.astro +711 -68
- package/template/src/components/endpoint/ResponseSnippets.astro +299 -173
- package/template/src/components/sidebar/SidebarEndpointLink.astro +1 -1
- package/template/src/components/ui/CodeLanguageIcon.astro +19 -0
- package/template/src/components/ui/CodeTabEdge.astro +79 -0
- package/template/src/components/ui/Field.astro +103 -20
- package/template/src/components/ui/Icon.astro +32 -0
- package/template/src/components/ui/ListChevronsToggle.astro +31 -0
- package/template/src/components/ui/Tag.astro +1 -1
- package/template/src/components/user/{Accordian.astro → Accordion.astro} +6 -6
- package/template/src/components/user/Callout.astro +5 -9
- package/template/src/components/user/CodeBlock.astro +400 -0
- package/template/src/components/user/CodeGroup.astro +225 -0
- package/template/src/components/user/ComponentPreview.astro +1 -0
- package/template/src/components/user/ComponentPreviewBlock.astro +181 -0
- package/template/src/components/user/Image.astro +132 -0
- package/template/src/components/user/Steps.astro +1 -3
- package/template/src/components/user/Tabs.astro +2 -2
- package/template/src/content.config.ts +1 -0
- package/template/src/layouts/Layout.astro +109 -8
- package/template/src/lib/code/code-block.ts +546 -0
- package/template/src/lib/frontmatter-schema.ts +8 -7
- package/template/src/lib/mdx/remark-code-block-component.ts +342 -0
- package/template/src/lib/mdx/remark-demote-h1.ts +16 -0
- package/template/src/lib/pagefind.ts +19 -5
- package/template/src/lib/routes.ts +49 -31
- package/template/src/lib/utils.ts +20 -0
- package/template/src/lib/validation.ts +638 -200
- package/template/src/pages/[...slug].astro +18 -5
- package/template/src/styles/geist-mono.css +33 -0
- package/template/src/styles/global.css +89 -84
- package/template/src/styles/google-sans-flex.css +143 -0
- package/template/ec.config.mjs +0 -51
- /package/template/src/components/user/{AccordianGroup.astro → AccordionGroup.astro} +0 -0
package/dist/index.js
CHANGED
|
@@ -52,6 +52,29 @@ function getTemplateDir() {
|
|
|
52
52
|
function getContentDir(cacheDir) {
|
|
53
53
|
return path.join(cacheDir, "src/content/docs");
|
|
54
54
|
}
|
|
55
|
+
async function getDirectoryFingerprint(dir) {
|
|
56
|
+
const hash = crypto.createHash("sha256");
|
|
57
|
+
async function walk(currentDir) {
|
|
58
|
+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
59
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
62
|
+
const relativePath = path.relative(dir, fullPath);
|
|
63
|
+
if (entry.isDirectory()) {
|
|
64
|
+
hash.update(`dir:${relativePath}
|
|
65
|
+
`);
|
|
66
|
+
await walk(fullPath);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
hash.update(`file:${relativePath}
|
|
70
|
+
`);
|
|
71
|
+
hash.update(await fs.readFile(fullPath));
|
|
72
|
+
hash.update("\n");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
await walk(dir);
|
|
76
|
+
return hash.digest("hex");
|
|
77
|
+
}
|
|
55
78
|
async function validateUserDocs(docsDir) {
|
|
56
79
|
const docsJsonPath = path.join(docsDir, "docs.json");
|
|
57
80
|
if (!fs.existsSync(docsJsonPath)) {
|
|
@@ -80,14 +103,13 @@ async function setupCache(cacheDir) {
|
|
|
80
103
|
log.info(`Expected at: ${templateDir}`);
|
|
81
104
|
process.exit(1);
|
|
82
105
|
}
|
|
106
|
+
const templateFingerprint = await getDirectoryFingerprint(templateDir);
|
|
107
|
+
const cacheFingerprintPath = path.join(cacheDir, ".radiant-template-fingerprint");
|
|
83
108
|
let needsUpdate = !cacheExists;
|
|
84
109
|
if (cacheExists) {
|
|
85
110
|
try {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
const cachePkg = await fs.readJson(path.join(cacheDir, "package.json"));
|
|
90
|
-
if (templatePkg.version !== cachePkg.version) {
|
|
111
|
+
const cacheFingerprint = await fs.readFile(cacheFingerprintPath, "utf-8");
|
|
112
|
+
if (cacheFingerprint !== templateFingerprint) {
|
|
91
113
|
needsUpdate = true;
|
|
92
114
|
log.info("Framework update detected, refreshing cache...");
|
|
93
115
|
}
|
|
@@ -106,6 +128,7 @@ async function setupCache(cacheDir) {
|
|
|
106
128
|
return !relativePath.includes("node_modules");
|
|
107
129
|
}
|
|
108
130
|
});
|
|
131
|
+
await fs.writeFile(cacheFingerprintPath, templateFingerprint);
|
|
109
132
|
log.success("Framework copied to cache.");
|
|
110
133
|
return true;
|
|
111
134
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "radiant-docs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "CLI tool for previewing Radiant documentation locally",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"radiant": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsup src/index.ts --format esm --clean",
|
|
10
|
+
"build": "tsup src/index.ts --format esm --clean && npm run bundle-template",
|
|
11
11
|
"dev": "tsup src/index.ts --format esm --watch",
|
|
12
|
-
"prepublishOnly": "npm run build
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
13
|
"bundle-template": "node scripts/bundle-template.js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
@@ -4,10 +4,60 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
4
4
|
import mdx from "@astrojs/mdx";
|
|
5
5
|
import alpine from "@astrojs/alpinejs";
|
|
6
6
|
import icon from "astro-icon";
|
|
7
|
-
import expressiveCode from "astro-expressive-code";
|
|
8
7
|
import fs from "fs";
|
|
9
8
|
import path from "path";
|
|
10
9
|
import { getConfig, validateMdxContent } from "./src/lib/validation";
|
|
10
|
+
import remarkCodeBlockComponent from "./src/lib/mdx/remark-code-block-component";
|
|
11
|
+
import remarkDemoteH1 from "./src/lib/mdx/remark-demote-h1";
|
|
12
|
+
import rehypeSlug from "rehype-slug";
|
|
13
|
+
import rehypeAutolinkHeadings from "rehype-autolink-headings";
|
|
14
|
+
|
|
15
|
+
const headingAnchorIcon = {
|
|
16
|
+
type: "element",
|
|
17
|
+
tagName: "svg",
|
|
18
|
+
properties: {
|
|
19
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
+
width: "24",
|
|
21
|
+
height: "24",
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "none",
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
strokeWidth: "2",
|
|
26
|
+
strokeLinecap: "round",
|
|
27
|
+
strokeLinejoin: "round",
|
|
28
|
+
className: ["heading-anchor-icon"],
|
|
29
|
+
ariaHidden: "true",
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
{
|
|
33
|
+
type: "element",
|
|
34
|
+
tagName: "path",
|
|
35
|
+
properties: {
|
|
36
|
+
d: "M9 17H7A5 5 0 0 1 7 7h2",
|
|
37
|
+
},
|
|
38
|
+
children: [],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "element",
|
|
42
|
+
tagName: "path",
|
|
43
|
+
properties: {
|
|
44
|
+
d: "M15 7h2a5 5 0 1 1 0 10h-2",
|
|
45
|
+
},
|
|
46
|
+
children: [],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "element",
|
|
50
|
+
tagName: "line",
|
|
51
|
+
properties: {
|
|
52
|
+
x1: "8",
|
|
53
|
+
x2: "16",
|
|
54
|
+
y1: "12",
|
|
55
|
+
y2: "12",
|
|
56
|
+
},
|
|
57
|
+
children: [],
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
11
61
|
|
|
12
62
|
if (process.env.npm_lifecycle_event === "build") {
|
|
13
63
|
// Run validation for build before Astro's internal validation
|
|
@@ -198,8 +248,15 @@ function copyContentAssets() {
|
|
|
198
248
|
};
|
|
199
249
|
}
|
|
200
250
|
|
|
251
|
+
const configuredSite =
|
|
252
|
+
typeof process.env.DOCS_SITE_URL === "string" &&
|
|
253
|
+
process.env.DOCS_SITE_URL.trim().length > 0
|
|
254
|
+
? process.env.DOCS_SITE_URL.trim()
|
|
255
|
+
: undefined;
|
|
256
|
+
|
|
201
257
|
// https://astro.build/config
|
|
202
258
|
export default defineConfig({
|
|
259
|
+
site: configuredSite,
|
|
203
260
|
vite: {
|
|
204
261
|
plugins: [tailwindcss(), copyContentAssets()],
|
|
205
262
|
},
|
|
@@ -208,8 +265,24 @@ export default defineConfig({
|
|
|
208
265
|
format: "directory",
|
|
209
266
|
},
|
|
210
267
|
integrations: [
|
|
211
|
-
|
|
212
|
-
|
|
268
|
+
mdx({
|
|
269
|
+
remarkPlugins: [remarkDemoteH1, remarkCodeBlockComponent],
|
|
270
|
+
rehypePlugins: [
|
|
271
|
+
rehypeSlug,
|
|
272
|
+
[
|
|
273
|
+
rehypeAutolinkHeadings,
|
|
274
|
+
{
|
|
275
|
+
behavior: "append",
|
|
276
|
+
content: headingAnchorIcon,
|
|
277
|
+
properties: {
|
|
278
|
+
className: ["heading-anchor"],
|
|
279
|
+
ariaLabel: "Copy section link",
|
|
280
|
+
title: "Copy section link",
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
],
|
|
285
|
+
}),
|
|
213
286
|
alpine({ entrypoint: "/src/entrypoint" }),
|
|
214
287
|
icon(),
|
|
215
288
|
],
|