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.
Files changed (78) hide show
  1. package/dist/index.js +28 -5
  2. package/package.json +3 -3
  3. package/template/astro.config.mjs +76 -3
  4. package/template/package-lock.json +924 -737
  5. package/template/package.json +7 -5
  6. package/template/scripts/generate-og-images.mjs +335 -0
  7. package/template/scripts/generate-og-metadata.mjs +173 -0
  8. package/template/scripts/rewrite-static-asset-host.mjs +408 -0
  9. package/template/scripts/stamp-image-versions.mjs +277 -0
  10. package/template/scripts/stamp-og-image-versions.mjs +199 -0
  11. package/template/scripts/stamp-pagefind-runtime-version.mjs +140 -0
  12. package/template/src/assets/fonts/geist-mono/cyrillic.woff2 +0 -0
  13. package/template/src/assets/fonts/geist-mono/latin-ext.woff2 +0 -0
  14. package/template/src/assets/fonts/geist-mono/latin.woff2 +0 -0
  15. package/template/src/assets/fonts/google-sans-flex/canadian-aboriginal.woff2 +0 -0
  16. package/template/src/assets/fonts/google-sans-flex/cherokee.woff2 +0 -0
  17. package/template/src/assets/fonts/google-sans-flex/latin-ext.woff2 +0 -0
  18. package/template/src/assets/fonts/google-sans-flex/latin.woff2 +0 -0
  19. package/template/src/assets/fonts/google-sans-flex/math.woff2 +0 -0
  20. package/template/src/assets/fonts/google-sans-flex/nushu.woff2 +0 -0
  21. package/template/src/assets/fonts/google-sans-flex/symbols.woff2 +0 -0
  22. package/template/src/assets/fonts/google-sans-flex/syriac.woff2 +0 -0
  23. package/template/src/assets/fonts/google-sans-flex/tifinagh.woff2 +0 -0
  24. package/template/src/assets/fonts/google-sans-flex/vietnamese.woff2 +0 -0
  25. package/template/src/components/Footer.astro +94 -0
  26. package/template/src/components/Header.astro +11 -66
  27. package/template/src/components/LogoLink.astro +103 -0
  28. package/template/src/components/MdxPage.astro +126 -11
  29. package/template/src/components/OpenApiPage.astro +1036 -69
  30. package/template/src/components/Search.astro +0 -2
  31. package/template/src/components/SidebarDropdown.astro +34 -14
  32. package/template/src/components/SidebarGroup.astro +3 -6
  33. package/template/src/components/SidebarLink.astro +22 -12
  34. package/template/src/components/SidebarMenu.astro +19 -16
  35. package/template/src/components/SidebarSegmented.astro +99 -0
  36. package/template/src/components/SidebarSubgroup.astro +12 -12
  37. package/template/src/components/ThemeSwitcher.astro +30 -7
  38. package/template/src/components/endpoint/PlaygroundBar.astro +32 -36
  39. package/template/src/components/endpoint/PlaygroundButton.astro +40 -4
  40. package/template/src/components/endpoint/PlaygroundField.astro +1068 -22
  41. package/template/src/components/endpoint/PlaygroundForm.astro +559 -61
  42. package/template/src/components/endpoint/RequestSnippets.astro +342 -193
  43. package/template/src/components/endpoint/ResponseDisplay.astro +161 -147
  44. package/template/src/components/endpoint/ResponseFieldTree.astro +134 -0
  45. package/template/src/components/endpoint/ResponseFields.astro +711 -68
  46. package/template/src/components/endpoint/ResponseSnippets.astro +299 -173
  47. package/template/src/components/sidebar/SidebarEndpointLink.astro +1 -1
  48. package/template/src/components/ui/CodeLanguageIcon.astro +19 -0
  49. package/template/src/components/ui/CodeTabEdge.astro +79 -0
  50. package/template/src/components/ui/Field.astro +103 -20
  51. package/template/src/components/ui/Icon.astro +32 -0
  52. package/template/src/components/ui/ListChevronsToggle.astro +31 -0
  53. package/template/src/components/ui/Tag.astro +1 -1
  54. package/template/src/components/user/{Accordian.astro → Accordion.astro} +6 -6
  55. package/template/src/components/user/Callout.astro +5 -9
  56. package/template/src/components/user/CodeBlock.astro +400 -0
  57. package/template/src/components/user/CodeGroup.astro +225 -0
  58. package/template/src/components/user/ComponentPreview.astro +1 -0
  59. package/template/src/components/user/ComponentPreviewBlock.astro +181 -0
  60. package/template/src/components/user/Image.astro +132 -0
  61. package/template/src/components/user/Steps.astro +1 -3
  62. package/template/src/components/user/Tabs.astro +2 -2
  63. package/template/src/content.config.ts +1 -0
  64. package/template/src/layouts/Layout.astro +109 -8
  65. package/template/src/lib/code/code-block.ts +546 -0
  66. package/template/src/lib/frontmatter-schema.ts +8 -7
  67. package/template/src/lib/mdx/remark-code-block-component.ts +342 -0
  68. package/template/src/lib/mdx/remark-demote-h1.ts +16 -0
  69. package/template/src/lib/pagefind.ts +19 -5
  70. package/template/src/lib/routes.ts +49 -31
  71. package/template/src/lib/utils.ts +20 -0
  72. package/template/src/lib/validation.ts +638 -200
  73. package/template/src/pages/[...slug].astro +18 -5
  74. package/template/src/styles/geist-mono.css +33 -0
  75. package/template/src/styles/global.css +89 -84
  76. package/template/src/styles/google-sans-flex.css +143 -0
  77. package/template/ec.config.mjs +0 -51
  78. /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 templatePkg = await fs.readJson(
87
- path.join(templateDir, "package.json")
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.7",
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 && npm run bundle-template",
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
- expressiveCode(),
212
- mdx(),
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
  ],