blodemd 0.0.15 → 0.2.0

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 (286) hide show
  1. package/README.md +26 -1
  2. package/dist/cli.mjs +217 -217
  3. package/dist/cli.mjs.map +1 -1
  4. package/package.json +3 -36
  5. package/dev-server/app/[[...slug]]/page.tsx +0 -140
  6. package/dev-server/app/blodemd-dev/invalidate/route.ts +0 -12
  7. package/dev-server/app/blodemd-dev/static/[...path]/route.ts +0 -32
  8. package/dev-server/app/blodemd-dev/version/route.ts +0 -14
  9. package/dev-server/app/blodemd-internal/proxy/route.ts +0 -86
  10. package/dev-server/app/error.tsx +0 -24
  11. package/dev-server/app/favicon.ico +0 -0
  12. package/dev-server/app/globals.css +0 -4
  13. package/dev-server/app/layout.tsx +0 -38
  14. package/dev-server/app/not-found.tsx +0 -18
  15. package/dev-server/app/search/route.ts +0 -17
  16. package/dev-server/components/dev-reload-script.tsx +0 -86
  17. package/dev-server/components/providers.tsx +0 -15
  18. package/dev-server/lib/dev-state.ts +0 -8
  19. package/dev-server/lib/local-content-source.ts +0 -103
  20. package/dev-server/lib/local-runtime.tsx +0 -555
  21. package/dev-server/next-env.d.ts +0 -5
  22. package/dev-server/next.config.js +0 -54
  23. package/dev-server/package.json +0 -61
  24. package/dev-server/postcss.config.mjs +0 -7
  25. package/dev-server/public/glide-variable.woff2 +0 -0
  26. package/dev-server/tsconfig.json +0 -50
  27. package/docs/app/globals.css +0 -471
  28. package/docs/components/animate-ui/primitives/buttons/button.tsx +0 -14
  29. package/docs/components/api/api-playground.tsx +0 -467
  30. package/docs/components/api/api-reference.tsx +0 -157
  31. package/docs/components/content/collection-index.tsx +0 -114
  32. package/docs/components/docs/contextual-menu.tsx +0 -495
  33. package/docs/components/docs/copy-page-menu.tsx +0 -364
  34. package/docs/components/docs/doc-header.tsx +0 -223
  35. package/docs/components/docs/doc-shell.tsx +0 -355
  36. package/docs/components/docs/doc-sidebar.tsx +0 -256
  37. package/docs/components/docs/doc-toc.tsx +0 -46
  38. package/docs/components/docs/mobile-nav.tsx +0 -195
  39. package/docs/components/docs/sidebar-active-highlight.tsx +0 -34
  40. package/docs/components/docs/sidebar-scroll-area.tsx +0 -63
  41. package/docs/components/git/repo-picker.tsx +0 -529
  42. package/docs/components/icons/doc-icon.tsx +0 -96
  43. package/docs/components/mdx/accordion.tsx +0 -83
  44. package/docs/components/mdx/agent-instructions.tsx +0 -17
  45. package/docs/components/mdx/badge.tsx +0 -79
  46. package/docs/components/mdx/callout.tsx +0 -88
  47. package/docs/components/mdx/card.tsx +0 -110
  48. package/docs/components/mdx/code-block.tsx +0 -80
  49. package/docs/components/mdx/code-group.tsx +0 -203
  50. package/docs/components/mdx/color.tsx +0 -87
  51. package/docs/components/mdx/columns.tsx +0 -25
  52. package/docs/components/mdx/expandable.tsx +0 -45
  53. package/docs/components/mdx/field-layout.tsx +0 -77
  54. package/docs/components/mdx/frame.tsx +0 -23
  55. package/docs/components/mdx/get-text-content.ts +0 -18
  56. package/docs/components/mdx/icon.tsx +0 -12
  57. package/docs/components/mdx/iframe.tsx +0 -62
  58. package/docs/components/mdx/index.tsx +0 -121
  59. package/docs/components/mdx/installer.tsx +0 -20
  60. package/docs/components/mdx/panel.tsx +0 -11
  61. package/docs/components/mdx/param-field.tsx +0 -56
  62. package/docs/components/mdx/preview.tsx +0 -36
  63. package/docs/components/mdx/prompt.tsx +0 -63
  64. package/docs/components/mdx/request-example.tsx +0 -27
  65. package/docs/components/mdx/response-field.tsx +0 -42
  66. package/docs/components/mdx/steps.tsx +0 -92
  67. package/docs/components/mdx/tabs.tsx +0 -193
  68. package/docs/components/mdx/tile.tsx +0 -43
  69. package/docs/components/mdx/tooltip.tsx +0 -71
  70. package/docs/components/mdx/tree.tsx +0 -120
  71. package/docs/components/mdx/type-table.tsx +0 -71
  72. package/docs/components/mdx/update.tsx +0 -44
  73. package/docs/components/mdx/video.tsx +0 -45
  74. package/docs/components/mdx/view.tsx +0 -66
  75. package/docs/components/posthog-provider.tsx +0 -42
  76. package/docs/components/providers.tsx +0 -15
  77. package/docs/components/tenant-analytics.tsx +0 -49
  78. package/docs/components/third-parties.tsx +0 -32
  79. package/docs/components/ui/badge.tsx +0 -61
  80. package/docs/components/ui/breadcrumb.tsx +0 -112
  81. package/docs/components/ui/button-group.tsx +0 -83
  82. package/docs/components/ui/button.tsx +0 -65
  83. package/docs/components/ui/card.tsx +0 -92
  84. package/docs/components/ui/command.tsx +0 -167
  85. package/docs/components/ui/copy-button.tsx +0 -129
  86. package/docs/components/ui/dialog.tsx +0 -146
  87. package/docs/components/ui/field.tsx +0 -237
  88. package/docs/components/ui/input.tsx +0 -23
  89. package/docs/components/ui/kbd.tsx +0 -98
  90. package/docs/components/ui/label.tsx +0 -22
  91. package/docs/components/ui/morph-icon.tsx +0 -79
  92. package/docs/components/ui/popover.tsx +0 -267
  93. package/docs/components/ui/search-dialog.tsx +0 -431
  94. package/docs/components/ui/search.tsx +0 -101
  95. package/docs/components/ui/separator.tsx +0 -26
  96. package/docs/components/ui/sheet.tsx +0 -133
  97. package/docs/components/ui/sidebar.tsx +0 -758
  98. package/docs/components/ui/skeleton.tsx +0 -11
  99. package/docs/components/ui/switch.tsx +0 -32
  100. package/docs/components/ui/tabs.tsx +0 -138
  101. package/docs/components/ui/theme-toggle.tsx +0 -62
  102. package/docs/components/ui/tooltip.tsx +0 -53
  103. package/docs/components/web-mcp.tsx +0 -115
  104. package/docs/lib/agent-skills.ts +0 -48
  105. package/docs/lib/api-client.ts +0 -72
  106. package/docs/lib/config.ts +0 -6
  107. package/docs/lib/content-root.ts +0 -33
  108. package/docs/lib/content-source.ts +0 -70
  109. package/docs/lib/contextual-options.ts +0 -222
  110. package/docs/lib/dashboard-session.ts +0 -167
  111. package/docs/lib/db.ts +0 -13
  112. package/docs/lib/docs-collection.ts +0 -7
  113. package/docs/lib/docs-runtime.tsx +0 -745
  114. package/docs/lib/edge-config.ts +0 -95
  115. package/docs/lib/env.ts +0 -23
  116. package/docs/lib/etag.ts +0 -22
  117. package/docs/lib/github-install.ts +0 -33
  118. package/docs/lib/llms-full.ts +0 -82
  119. package/docs/lib/marketing-markdown.ts +0 -79
  120. package/docs/lib/marketing-site.ts +0 -31
  121. package/docs/lib/mdx.ts +0 -98
  122. package/docs/lib/navigation.ts +0 -288
  123. package/docs/lib/openapi-proxy.ts +0 -88
  124. package/docs/lib/openapi.ts +0 -158
  125. package/docs/lib/platform-config.ts +0 -6
  126. package/docs/lib/project-authz.ts +0 -46
  127. package/docs/lib/routes.ts +0 -103
  128. package/docs/lib/server-cache.ts +0 -83
  129. package/docs/lib/shiki.ts +0 -44
  130. package/docs/lib/supabase.ts +0 -37
  131. package/docs/lib/tenancy.ts +0 -364
  132. package/docs/lib/tenant-headers.ts +0 -43
  133. package/docs/lib/tenant-static.ts +0 -705
  134. package/docs/lib/tenant-utility-context.ts +0 -62
  135. package/docs/lib/tenants.ts +0 -72
  136. package/docs/lib/theme.ts +0 -29
  137. package/docs/lib/time-ago.ts +0 -24
  138. package/docs/lib/toc.ts +0 -2
  139. package/docs/lib/use-mobile.ts +0 -19
  140. package/docs/lib/use-tab-observer.ts +0 -71
  141. package/docs/lib/utils.ts +0 -5
  142. package/packages/@repo/common/dist/index.d.ts +0 -16
  143. package/packages/@repo/common/dist/index.d.ts.map +0 -1
  144. package/packages/@repo/common/dist/index.js +0 -84
  145. package/packages/@repo/common/package.json +0 -34
  146. package/packages/@repo/common/src/index.ts +0 -101
  147. package/packages/@repo/contracts/dist/analytics.d.ts +0 -21
  148. package/packages/@repo/contracts/dist/analytics.d.ts.map +0 -1
  149. package/packages/@repo/contracts/dist/analytics.js +0 -18
  150. package/packages/@repo/contracts/dist/dates.d.ts +0 -4
  151. package/packages/@repo/contracts/dist/dates.d.ts.map +0 -1
  152. package/packages/@repo/contracts/dist/dates.js +0 -2
  153. package/packages/@repo/contracts/dist/deployment.d.ts +0 -71
  154. package/packages/@repo/contracts/dist/deployment.d.ts.map +0 -1
  155. package/packages/@repo/contracts/dist/deployment.js +0 -46
  156. package/packages/@repo/contracts/dist/domain.d.ts +0 -94
  157. package/packages/@repo/contracts/dist/domain.d.ts.map +0 -1
  158. package/packages/@repo/contracts/dist/domain.js +0 -36
  159. package/packages/@repo/contracts/dist/git.d.ts +0 -28
  160. package/packages/@repo/contracts/dist/git.d.ts.map +0 -1
  161. package/packages/@repo/contracts/dist/git.js +0 -24
  162. package/packages/@repo/contracts/dist/ids.d.ts +0 -14
  163. package/packages/@repo/contracts/dist/ids.d.ts.map +0 -1
  164. package/packages/@repo/contracts/dist/ids.js +0 -11
  165. package/packages/@repo/contracts/dist/index.d.ts +0 -11
  166. package/packages/@repo/contracts/dist/index.d.ts.map +0 -1
  167. package/packages/@repo/contracts/dist/index.js +0 -12
  168. package/packages/@repo/contracts/dist/pagination.d.ts +0 -23
  169. package/packages/@repo/contracts/dist/pagination.d.ts.map +0 -1
  170. package/packages/@repo/contracts/dist/pagination.js +0 -15
  171. package/packages/@repo/contracts/dist/project.d.ts +0 -42
  172. package/packages/@repo/contracts/dist/project.d.ts.map +0 -1
  173. package/packages/@repo/contracts/dist/project.js +0 -25
  174. package/packages/@repo/contracts/dist/tenant.d.ts +0 -147
  175. package/packages/@repo/contracts/dist/tenant.d.ts.map +0 -1
  176. package/packages/@repo/contracts/dist/tenant.js +0 -58
  177. package/packages/@repo/contracts/dist/user.d.ts +0 -9
  178. package/packages/@repo/contracts/dist/user.d.ts.map +0 -1
  179. package/packages/@repo/contracts/dist/user.js +0 -9
  180. package/packages/@repo/contracts/package.json +0 -37
  181. package/packages/@repo/contracts/src/analytics.ts +0 -33
  182. package/packages/@repo/contracts/src/dates.ts +0 -4
  183. package/packages/@repo/contracts/src/deployment.ts +0 -73
  184. package/packages/@repo/contracts/src/domain.ts +0 -51
  185. package/packages/@repo/contracts/src/git.ts +0 -31
  186. package/packages/@repo/contracts/src/ids.ts +0 -23
  187. package/packages/@repo/contracts/src/index.ts +0 -12
  188. package/packages/@repo/contracts/src/pagination.ts +0 -21
  189. package/packages/@repo/contracts/src/project.ts +0 -32
  190. package/packages/@repo/contracts/src/tenant.ts +0 -94
  191. package/packages/@repo/contracts/src/user.ts +0 -12
  192. package/packages/@repo/models/dist/docs-config.d.ts +0 -961
  193. package/packages/@repo/models/dist/docs-config.d.ts.map +0 -1
  194. package/packages/@repo/models/dist/docs-config.js +0 -531
  195. package/packages/@repo/models/dist/index.d.ts +0 -3
  196. package/packages/@repo/models/dist/index.d.ts.map +0 -1
  197. package/packages/@repo/models/dist/index.js +0 -3
  198. package/packages/@repo/models/dist/tenant.d.ts +0 -37
  199. package/packages/@repo/models/dist/tenant.d.ts.map +0 -1
  200. package/packages/@repo/models/dist/tenant.js +0 -1
  201. package/packages/@repo/models/package.json +0 -37
  202. package/packages/@repo/models/src/docs-config.ts +0 -629
  203. package/packages/@repo/models/src/index.ts +0 -3
  204. package/packages/@repo/models/src/tenant.ts +0 -44
  205. package/packages/@repo/prebuild/dist/index.d.ts +0 -2
  206. package/packages/@repo/prebuild/dist/index.d.ts.map +0 -1
  207. package/packages/@repo/prebuild/dist/index.js +0 -2
  208. package/packages/@repo/prebuild/dist/openapi.d.ts +0 -43
  209. package/packages/@repo/prebuild/dist/openapi.d.ts.map +0 -1
  210. package/packages/@repo/prebuild/dist/openapi.js +0 -86
  211. package/packages/@repo/prebuild/package.json +0 -39
  212. package/packages/@repo/prebuild/src/index.ts +0 -2
  213. package/packages/@repo/prebuild/src/openapi.ts +0 -154
  214. package/packages/@repo/previewing/dist/blob-source.d.ts +0 -16
  215. package/packages/@repo/previewing/dist/blob-source.d.ts.map +0 -1
  216. package/packages/@repo/previewing/dist/blob-source.js +0 -128
  217. package/packages/@repo/previewing/dist/config-loader.d.ts +0 -134
  218. package/packages/@repo/previewing/dist/config-loader.d.ts.map +0 -1
  219. package/packages/@repo/previewing/dist/config-loader.js +0 -231
  220. package/packages/@repo/previewing/dist/constants.d.ts +0 -15
  221. package/packages/@repo/previewing/dist/constants.d.ts.map +0 -1
  222. package/packages/@repo/previewing/dist/constants.js +0 -14
  223. package/packages/@repo/previewing/dist/content-index.d.ts +0 -7
  224. package/packages/@repo/previewing/dist/content-index.d.ts.map +0 -1
  225. package/packages/@repo/previewing/dist/content-index.js +0 -291
  226. package/packages/@repo/previewing/dist/content-source.d.ts +0 -12
  227. package/packages/@repo/previewing/dist/content-source.d.ts.map +0 -1
  228. package/packages/@repo/previewing/dist/content-source.js +0 -1
  229. package/packages/@repo/previewing/dist/fs-source.d.ts +0 -11
  230. package/packages/@repo/previewing/dist/fs-source.d.ts.map +0 -1
  231. package/packages/@repo/previewing/dist/fs-source.js +0 -71
  232. package/packages/@repo/previewing/dist/index.d.ts +0 -16
  233. package/packages/@repo/previewing/dist/index.d.ts.map +0 -1
  234. package/packages/@repo/previewing/dist/index.js +0 -13
  235. package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts +0 -3
  236. package/packages/@repo/previewing/dist/markdown/agent-markdown.d.ts.map +0 -1
  237. package/packages/@repo/previewing/dist/markdown/agent-markdown.js +0 -176
  238. package/packages/@repo/previewing/dist/markdown/format.d.ts +0 -8
  239. package/packages/@repo/previewing/dist/markdown/format.d.ts.map +0 -1
  240. package/packages/@repo/previewing/dist/markdown/format.js +0 -43
  241. package/packages/@repo/previewing/dist/markdown/links.d.ts +0 -3
  242. package/packages/@repo/previewing/dist/markdown/links.d.ts.map +0 -1
  243. package/packages/@repo/previewing/dist/markdown/links.js +0 -31
  244. package/packages/@repo/previewing/dist/openapi-pages.d.ts +0 -7
  245. package/packages/@repo/previewing/dist/openapi-pages.d.ts.map +0 -1
  246. package/packages/@repo/previewing/dist/openapi-pages.js +0 -200
  247. package/packages/@repo/previewing/dist/search-index.d.ts +0 -4
  248. package/packages/@repo/previewing/dist/search-index.d.ts.map +0 -1
  249. package/packages/@repo/previewing/dist/search-index.js +0 -23
  250. package/packages/@repo/previewing/dist/serialization.d.ts +0 -13
  251. package/packages/@repo/previewing/dist/serialization.d.ts.map +0 -1
  252. package/packages/@repo/previewing/dist/serialization.js +0 -108
  253. package/packages/@repo/previewing/dist/toc-index.d.ts +0 -5
  254. package/packages/@repo/previewing/dist/toc-index.d.ts.map +0 -1
  255. package/packages/@repo/previewing/dist/toc-index.js +0 -53
  256. package/packages/@repo/previewing/dist/types.d.ts +0 -92
  257. package/packages/@repo/previewing/dist/types.d.ts.map +0 -1
  258. package/packages/@repo/previewing/dist/types.js +0 -1
  259. package/packages/@repo/previewing/dist/utility-index.d.ts +0 -7
  260. package/packages/@repo/previewing/dist/utility-index.d.ts.map +0 -1
  261. package/packages/@repo/previewing/dist/utility-index.js +0 -201
  262. package/packages/@repo/previewing/package.json +0 -41
  263. package/packages/@repo/previewing/src/blob-source.ts +0 -185
  264. package/packages/@repo/previewing/src/config-loader.ts +0 -316
  265. package/packages/@repo/previewing/src/constants.ts +0 -16
  266. package/packages/@repo/previewing/src/content-index.ts +0 -384
  267. package/packages/@repo/previewing/src/content-source.ts +0 -12
  268. package/packages/@repo/previewing/src/fs-source.ts +0 -103
  269. package/packages/@repo/previewing/src/index.ts +0 -71
  270. package/packages/@repo/previewing/src/markdown/agent-markdown.ts +0 -254
  271. package/packages/@repo/previewing/src/markdown/format.ts +0 -63
  272. package/packages/@repo/previewing/src/markdown/links.ts +0 -46
  273. package/packages/@repo/previewing/src/openapi-pages.ts +0 -319
  274. package/packages/@repo/previewing/src/search-index.ts +0 -38
  275. package/packages/@repo/previewing/src/serialization.ts +0 -191
  276. package/packages/@repo/previewing/src/toc-index.ts +0 -72
  277. package/packages/@repo/previewing/src/types.ts +0 -105
  278. package/packages/@repo/previewing/src/utility-index.ts +0 -304
  279. package/packages/@repo/validation/dist/index.d.ts +0 -12
  280. package/packages/@repo/validation/dist/index.d.ts.map +0 -1
  281. package/packages/@repo/validation/dist/index.js +0 -30
  282. package/packages/@repo/validation/package.json +0 -38
  283. package/packages/@repo/validation/src/blodemd-docs-schema.json +0 -3575
  284. package/packages/@repo/validation/src/index.ts +0 -59
  285. package/scripts/prepare-package.mjs +0 -53
  286. package/scripts/repo-packages.mjs +0 -8
@@ -1,185 +0,0 @@
1
- import path from "node:path";
2
-
3
- import { normalizePath, shouldIgnoreRootDocsFile } from "@repo/common";
4
-
5
- import type { CompiledMdxResult, ContentSource } from "./content-source.js";
6
-
7
- interface BlobManifestFile {
8
- path: string;
9
- url: string;
10
- }
11
-
12
- interface BlobManifest {
13
- files: BlobManifestFile[];
14
- }
15
-
16
- type FetchInitWithNext = RequestInit & {
17
- next?: {
18
- revalidate?: number;
19
- tags?: string[];
20
- };
21
- };
22
-
23
- const isRecord = (value: unknown): value is Record<string, unknown> =>
24
- typeof value === "object" && value !== null;
25
-
26
- const isBlobManifest = (value: unknown): value is BlobManifest => {
27
- if (!isRecord(value) || !Array.isArray(value.files)) {
28
- return false;
29
- }
30
-
31
- return value.files.every((file) => {
32
- if (!isRecord(file)) {
33
- return false;
34
- }
35
-
36
- return typeof file.path === "string" && typeof file.url === "string";
37
- });
38
- };
39
-
40
- const normalizeDirectory = (directory: string) => {
41
- const normalized = normalizePath(path.posix.normalize(directory));
42
- if (!normalized || normalized === ".") {
43
- return "";
44
- }
45
- return normalized ? `${normalized}/` : "";
46
- };
47
-
48
- const normalizeRelativePath = (value: string) =>
49
- normalizePath(path.posix.normalize(value));
50
-
51
- export class BlobContentSource implements ContentSource {
52
- private readonly manifestUrl: string;
53
- private readonly cacheTag?: string;
54
- private manifestPromise?: Promise<Map<string, string>>;
55
-
56
- constructor(manifestUrl: string, cacheTag?: string) {
57
- this.manifestUrl = manifestUrl;
58
- this.cacheTag = cacheTag;
59
- }
60
-
61
- private getFetchOptions(): FetchInitWithNext {
62
- if (!this.cacheTag) {
63
- return { cache: "no-store" };
64
- }
65
-
66
- return {
67
- next: {
68
- revalidate: 3600,
69
- tags: [this.cacheTag],
70
- },
71
- };
72
- }
73
-
74
- private async loadManifest(): Promise<Map<string, string>> {
75
- if (!this.manifestPromise) {
76
- this.manifestPromise = (async () => {
77
- const response = await fetch(this.manifestUrl, this.getFetchOptions());
78
- if (!response.ok) {
79
- throw new Error(
80
- `Failed to load deployment manifest: ${response.status}`
81
- );
82
- }
83
-
84
- const manifest = (await response.json()) as unknown;
85
- if (!isBlobManifest(manifest)) {
86
- throw new Error("Deployment manifest is invalid.");
87
- }
88
-
89
- return new Map(
90
- manifest.files.map((file) => [
91
- normalizeRelativePath(file.path),
92
- file.url,
93
- ])
94
- );
95
- })();
96
- }
97
-
98
- return await this.manifestPromise;
99
- }
100
-
101
- async readFile(relativePath: string): Promise<string> {
102
- const url = await this.resolveUrl(relativePath);
103
- if (!url) {
104
- throw new Error(`Content file "${relativePath}" not found.`);
105
- }
106
-
107
- const response = await fetch(url, this.getFetchOptions());
108
- if (!response.ok) {
109
- throw new Error(`Failed to load content file: ${response.status}`);
110
- }
111
-
112
- return await response.text();
113
- }
114
-
115
- async listFiles(directory: string): Promise<string[]> {
116
- const manifest = await this.loadManifest();
117
- const prefix = normalizeDirectory(directory);
118
-
119
- const files: string[] = [];
120
- for (const file of manifest.keys()) {
121
- if (prefix && !file.startsWith(prefix)) {
122
- continue;
123
- }
124
- // Return paths relative to the listed directory, matching
125
- // FsContentSource so callers can join them onto the collection root.
126
- const relativePath = prefix ? file.slice(prefix.length) : file;
127
- if (!relativePath) {
128
- continue;
129
- }
130
- // Only top-level entries of the listed directory are subject to the
131
- // root-docs-file ignore list, again matching FsContentSource.
132
- if (
133
- !relativePath.includes("/") &&
134
- shouldIgnoreRootDocsFile(relativePath)
135
- ) {
136
- continue;
137
- }
138
- files.push(relativePath);
139
- }
140
- // oxlint-disable-next-line eslint-plugin-unicorn/no-array-sort
141
- files.sort();
142
- return files;
143
- }
144
-
145
- async exists(relativePath: string): Promise<boolean> {
146
- const manifest = await this.loadManifest();
147
- return manifest.has(normalizeRelativePath(relativePath));
148
- }
149
-
150
- async resolveUrl(relativePath: string): Promise<string | null> {
151
- const manifest = await this.loadManifest();
152
- return manifest.get(normalizeRelativePath(relativePath)) ?? null;
153
- }
154
-
155
- async readCompiledMdx(
156
- relativePath: string
157
- ): Promise<CompiledMdxResult | null> {
158
- const compiledPath = `_compiled/${normalizeRelativePath(relativePath)}.json`;
159
- const url = await this.resolveUrl(compiledPath);
160
- if (!url) {
161
- return null;
162
- }
163
-
164
- try {
165
- const response = await fetch(url, this.getFetchOptions());
166
- if (!response.ok) {
167
- return null;
168
- }
169
-
170
- const data = (await response.json()) as CompiledMdxResult;
171
- if (!data.compiledSource || data.version !== 1) {
172
- return null;
173
- }
174
-
175
- return data;
176
- } catch {
177
- return null;
178
- }
179
- }
180
- }
181
-
182
- export const createBlobSource = (
183
- manifestUrl: string,
184
- cacheTag?: string
185
- ): ContentSource => new BlobContentSource(manifestUrl, cacheTag);
@@ -1,316 +0,0 @@
1
- import path from "node:path";
2
-
3
- import { normalizePath } from "@repo/common";
4
- import type { DocsConfig, SiteConfig } from "@repo/models";
5
- import { validateDocsConfig, validateSiteConfig } from "@repo/validation";
6
-
7
- import { LEGACY_PROJECT_NAME_FALLBACK_WARNING } from "./constants.js";
8
- import type { ContentSource } from "./content-source.js";
9
- import type { SiteConfigResult } from "./types.js";
10
-
11
- const DOCS_CONFIG_FILE = "docs.json";
12
-
13
- const defaultLinkLabel = (input: {
14
- href: string;
15
- label?: string;
16
- type?: "discord" | "github";
17
- }) => {
18
- if (input.label) {
19
- return input.label;
20
- }
21
- if (input.type === "github") {
22
- return "GitHub";
23
- }
24
- if (input.type === "discord") {
25
- return "Discord";
26
- }
27
- try {
28
- return new URL(input.href).hostname;
29
- } catch {
30
- return input.href;
31
- }
32
- };
33
-
34
- // oxlint-disable-next-line eslint/complexity
35
- const mapDocsConfig = (docs: DocsConfig): SiteConfig => {
36
- const navigation = {
37
- global:
38
- docs.navbar?.links?.length || docs.navigation.global?.anchors?.length
39
- ? {
40
- anchors: docs.navigation.global?.anchors?.map((anchor) => ({
41
- href: anchor.href,
42
- label: anchor.anchor,
43
- })),
44
- links: docs.navbar?.links?.map((link) => ({
45
- href: link.href,
46
- label: defaultLinkLabel(link),
47
- })),
48
- }
49
- : undefined,
50
- groups: docs.navigation.groups?.map((group) => ({
51
- expanded: group.expanded,
52
- group: group.group,
53
- hidden: group.hidden,
54
- pages: group.root
55
- ? [
56
- group.root,
57
- ...(group.pages ?? []).filter((page) => page !== group.root),
58
- ]
59
- : group.pages,
60
- })),
61
- languages: docs.navigation.languages?.map((language) => ({
62
- label: language.language,
63
- locale: language.language,
64
- url: language.href,
65
- })),
66
- pages: docs.navigation.pages,
67
- tabs: docs.navigation.tabs?.map((tab) => ({
68
- groups: tab.groups?.map((group) => ({
69
- expanded: group.expanded,
70
- group: group.group,
71
- hidden: group.hidden,
72
- pages: group.root
73
- ? [
74
- group.root,
75
- ...(group.pages ?? []).filter((page) => page !== group.root),
76
- ]
77
- : group.pages,
78
- })),
79
- href: tab.href,
80
- icon: tab.icon,
81
- label: tab.tab,
82
- pages: tab.pages,
83
- })),
84
- versions: docs.navigation.versions?.map((version) => ({
85
- label: version.version,
86
- url: version.href,
87
- })),
88
- } satisfies SiteConfig["navigation"];
89
-
90
- return {
91
- collections: [
92
- {
93
- id: "docs",
94
- navigation,
95
- openapi: docs.api?.openapi,
96
- root: "",
97
- type: "docs",
98
- },
99
- ],
100
- contextual: docs.contextual,
101
- description: docs.description,
102
- favicon:
103
- typeof docs.favicon === "string" ? docs.favicon : docs.favicon?.light,
104
- features: {
105
- rightToc: true,
106
- search: true,
107
- themeToggle: docs.appearance?.strict !== true,
108
- toc: true,
109
- },
110
- logo: docs.logo
111
- ? {
112
- dark: typeof docs.logo === "string" ? docs.logo : docs.logo.dark,
113
- href: typeof docs.logo === "string" ? undefined : docs.logo.href,
114
- light: typeof docs.logo === "string" ? docs.logo : docs.logo.light,
115
- }
116
- : undefined,
117
- name: docs.name,
118
- navigation,
119
- openapiProxy: {
120
- enabled:
121
- docs.api?.playground?.proxy !== false &&
122
- Boolean(docs.api?.openapi || docs.api?.asyncapi),
123
- },
124
- seo: docs.seo,
125
- slug: docs.slug,
126
- };
127
- };
128
-
129
- const getProjectWarnings = (config: { slug?: string }): string[] =>
130
- config.slug ? [] : [LEGACY_PROJECT_NAME_FALLBACK_WARNING];
131
-
132
- const readJsonConfig = async (source: ContentSource, relativePath: string) =>
133
- JSON.parse(await source.readFile(relativePath)) as unknown;
134
-
135
- const normalizeRefPath = (baseDirectory: string, reference: string) => {
136
- if (
137
- reference.startsWith("/") ||
138
- reference.startsWith("\\") ||
139
- reference.startsWith("http://") ||
140
- reference.startsWith("https://")
141
- ) {
142
- throw new Error(
143
- `Invalid $ref "${reference}". Only relative JSON files are supported.`
144
- );
145
- }
146
-
147
- const normalized = normalizePath(path.posix.join(baseDirectory, reference));
148
- if (
149
- !normalized ||
150
- normalized === "." ||
151
- normalized.startsWith("../") ||
152
- normalized.includes("/../")
153
- ) {
154
- throw new Error(`Invalid $ref "${reference}".`);
155
- }
156
- return normalized;
157
- };
158
-
159
- const resolveJsonRefs = async (
160
- source: ContentSource,
161
- value: unknown,
162
- baseDirectory: string,
163
- seen: Set<string>
164
- ): Promise<unknown> => {
165
- if (Array.isArray(value)) {
166
- return await Promise.all(
167
- value.map((item) => resolveJsonRefs(source, item, baseDirectory, seen))
168
- );
169
- }
170
-
171
- if (!value || typeof value !== "object") {
172
- return value;
173
- }
174
-
175
- const record = value as Record<string, unknown>;
176
- const reference = record.$ref;
177
- if (typeof reference === "string") {
178
- const resolvedPath = normalizeRefPath(baseDirectory, reference);
179
- if (seen.has(resolvedPath)) {
180
- throw new Error(`Circular $ref detected for "${resolvedPath}".`);
181
- }
182
-
183
- const nextSeen = new Set(seen);
184
- // oxlint-disable-next-line eslint-plugin-unicorn/no-immediate-mutation
185
- nextSeen.add(resolvedPath);
186
- const referenced = await readJsonConfig(source, resolvedPath);
187
- const referencedValue = await resolveJsonRefs(
188
- source,
189
- referenced,
190
- path.posix.dirname(resolvedPath) === "."
191
- ? ""
192
- : normalizePath(path.posix.dirname(resolvedPath)),
193
- nextSeen
194
- );
195
-
196
- const siblingEntries = Object.entries(record).filter(
197
- ([key]) => key !== "$ref"
198
- );
199
- if (
200
- !siblingEntries.length ||
201
- !referencedValue ||
202
- typeof referencedValue !== "object" ||
203
- Array.isArray(referencedValue)
204
- ) {
205
- return referencedValue;
206
- }
207
-
208
- const siblingValue = await resolveJsonRefs(
209
- source,
210
- Object.fromEntries(siblingEntries),
211
- baseDirectory,
212
- seen
213
- );
214
- return {
215
- ...(referencedValue as Record<string, unknown>),
216
- ...(siblingValue as Record<string, unknown>),
217
- };
218
- }
219
-
220
- const resolvedEntries = await Promise.all(
221
- Object.entries(record).map(async ([key, entryValue]) => [
222
- key,
223
- await resolveJsonRefs(source, entryValue, baseDirectory, seen),
224
- ])
225
- );
226
- return Object.fromEntries(resolvedEntries);
227
- };
228
-
229
- const readResolvedJsonConfig = async (
230
- source: ContentSource,
231
- relativePath: string
232
- ) =>
233
- await resolveJsonRefs(
234
- source,
235
- await readJsonConfig(source, relativePath),
236
- path.posix.dirname(relativePath) === "."
237
- ? ""
238
- : normalizePath(path.posix.dirname(relativePath)),
239
- new Set([relativePath])
240
- );
241
-
242
- const loadDocsConfig = async (
243
- source: ContentSource
244
- ): Promise<SiteConfigResult | null> => {
245
- if (!(await source.exists(DOCS_CONFIG_FILE))) {
246
- return null;
247
- }
248
-
249
- try {
250
- const parsed = await readResolvedJsonConfig(source, DOCS_CONFIG_FILE);
251
-
252
- // Try SiteConfig format first (has collections, theme, colors, etc.)
253
- const siteResult = validateSiteConfig(parsed);
254
- if (siteResult.success) {
255
- return {
256
- config: siteResult.data,
257
- ok: true,
258
- warnings: getProjectWarnings(siteResult.data),
259
- };
260
- }
261
-
262
- // Fall back to DocsConfig format (Mintlify-compatible) and map to SiteConfig
263
- const docsResult = validateDocsConfig(parsed);
264
- if (docsResult.success) {
265
- return {
266
- config: mapDocsConfig(docsResult.data),
267
- ok: true,
268
- warnings: getProjectWarnings(docsResult.data),
269
- };
270
- }
271
-
272
- return { errors: docsResult.errors, ok: false };
273
- } catch (error) {
274
- return {
275
- errors: [
276
- error instanceof Error
277
- ? error.message
278
- : `Failed to load ${DOCS_CONFIG_FILE}`,
279
- ],
280
- ok: false,
281
- };
282
- }
283
- };
284
-
285
- export const loadSiteConfig = async (
286
- source: ContentSource
287
- ): Promise<SiteConfigResult> => {
288
- const docsConfig = await loadDocsConfig(source);
289
- if (docsConfig) {
290
- return docsConfig;
291
- }
292
-
293
- return {
294
- errors: [`${DOCS_CONFIG_FILE} not found.`],
295
- ok: false,
296
- };
297
- };
298
-
299
- export const getDocsCollection = (config: SiteConfig) =>
300
- config.collections.find((collection) => collection.type === "docs");
301
-
302
- export const getDocsNavigation = (config: SiteConfig) =>
303
- getDocsCollection(config)?.navigation ?? config.navigation;
304
-
305
- export const getDocsCollectionWithNavigation = (
306
- config: SiteConfig
307
- ): SiteConfig["collections"][number] | undefined => {
308
- const docsCollection = getDocsCollection(config);
309
- const docsNavigation = getDocsNavigation(config);
310
-
311
- return docsCollection &&
312
- docsNavigation &&
313
- docsCollection.navigation !== docsNavigation
314
- ? { ...docsCollection, navigation: docsNavigation }
315
- : docsCollection;
316
- };
@@ -1,16 +0,0 @@
1
- export const PREBUILT_INDEX_PATH = "_content-index.json";
2
- export const PREBUILT_OPENAPI_INDEX_PATH = "_openapi-index.json";
3
- export const PREBUILT_SEARCH_INDEX_PATH = "_search-index.json";
4
- export const PREBUILT_TOC_INDEX_PATH = "_toc-index.json";
5
- export const PREBUILT_UTILITY_INDEX_PATH = "_utility-index.json";
6
- export const PREBUILT_UTILITY_SITEMAP_PATH = "_utility/sitemap.xml";
7
- export const PREBUILT_UTILITY_LLMS_PATH = "_utility/llms.txt";
8
- export const PREBUILT_UTILITY_LLMS_FULL_PATH = "_utility/llms-full.txt";
9
- export const PREBUILT_UTILITY_LLMS_SEGMENT_PREFIX = "_utility/llms/";
10
- export const PREBUILT_UTILITY_SKILLS_INDEX_PATH = "_utility/skills-index.json";
11
- export const PREBUILT_UTILITY_SKILLS_MD_PREFIX = "_utility/skills/";
12
- export const UTILITY_DOCS_ROOT_TOKEN = "__BLODEMD_DOCS_ROOT__";
13
- export const LEGACY_PROJECT_NAME_FALLBACK_WARNING =
14
- "docs.json.slug is recommended. Falling back to docs.json.name as the deployment slug is deprecated.";
15
-
16
- export const NEWLINE_REGEX = /\r?\n/;