radiant-docs 0.1.34 → 0.1.38
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/package.json +1 -1
- package/template/astro.config.mjs +27 -0
- package/template/package-lock.json +1027 -513
- package/template/package.json +3 -2
- package/template/scripts/generate-proxy-allowed-origins.mjs +217 -0
- package/template/scripts/generate-robots-txt.mjs +19 -0
- package/template/scripts/stamp-image-versions.mjs +63 -11
- package/template/src/components/Footer.astro +1 -1
- package/template/src/components/Header.astro +9 -9
- package/template/src/components/LogoLink.astro +2 -1
- package/template/src/components/OpenApiPage.astro +18 -18
- package/template/src/components/Search.astro +18 -18
- package/template/src/components/Sidebar.astro +4 -2
- package/template/src/components/SidebarDropdown.astro +82 -79
- package/template/src/components/SidebarGroup.astro +3 -0
- package/template/src/components/SidebarMenu.astro +14 -1
- package/template/src/components/SidebarSegmented.astro +5 -5
- package/template/src/components/SidebarSubgroup.astro +35 -12
- package/template/src/components/TableOfContents.astro +24 -15
- package/template/src/components/ThemeSwitcher.astro +15 -8
- package/template/src/components/chat/AskAiWidget.tsx +10 -5
- package/template/src/components/endpoint/PlaygroundBar.astro +3 -3
- package/template/src/components/endpoint/PlaygroundButton.astro +3 -3
- package/template/src/components/endpoint/PlaygroundField.astro +53 -53
- package/template/src/components/endpoint/PlaygroundForm.astro +51 -37
- package/template/src/components/endpoint/RequestSnippets.astro +54 -21
- package/template/src/components/endpoint/ResponseDisplay.astro +24 -24
- package/template/src/components/endpoint/ResponseFieldTree.astro +12 -12
- package/template/src/components/endpoint/ResponseFields.astro +19 -19
- package/template/src/components/endpoint/ResponseSnippets.astro +66 -29
- package/template/src/components/sidebar/SidebarEndpointLink.astro +18 -15
- package/template/src/components/sidebar/SidebarOpenApiPageLink.astro +56 -0
- package/template/src/components/ui/CodeTabEdge.astro +6 -4
- package/template/src/components/ui/Field.astro +7 -7
- package/template/src/components/ui/Icon.astro +2 -1
- package/template/src/components/ui/demo/Demo.astro +1 -1
- package/template/src/components/user/Accordion.astro +3 -3
- package/template/src/components/user/Callout.astro +8 -8
- package/template/src/components/user/CodeBlock.astro +57 -22
- package/template/src/components/user/CodeGroup.astro +14 -10
- package/template/src/components/user/ComponentPreviewBlock.astro +38 -12
- package/template/src/components/user/Image.astro +6 -2
- package/template/src/components/user/Step.astro +4 -4
- package/template/src/components/user/Tab.astro +1 -1
- package/template/src/components/user/Tabs.astro +15 -20
- package/template/src/layouts/Layout.astro +9 -4
- package/template/src/lib/code/code-block.ts +150 -15
- package/template/src/lib/mdx/remark-resolve-internal-links.ts +639 -0
- package/template/src/lib/pagefind.ts +2 -1
- package/template/src/lib/routes.ts +134 -58
- package/template/src/lib/static-asset-url.ts +62 -0
- package/template/src/lib/utils.ts +48 -0
- package/template/src/lib/validation.ts +115 -27
- package/template/src/pages/404.astro +44 -0
- package/template/src/styles/global.css +28 -19
- package/template/scripts/rewrite-static-asset-host.mjs +0 -408
|
@@ -52,20 +52,24 @@ Object.entries(responses).forEach(([statusCode, response]: [string, any]) => {
|
|
|
52
52
|
|
|
53
53
|
const statusCodeStyles = {
|
|
54
54
|
"2": {
|
|
55
|
-
badge:
|
|
56
|
-
|
|
55
|
+
badge:
|
|
56
|
+
"bg-green-50 text-green-700/70 border-green-700/10 dark:bg-green-900/30 dark:text-green-300 dark:border-green-300/20",
|
|
57
|
+
dot: "bg-green-700/70 dark:bg-green-400/80",
|
|
57
58
|
},
|
|
58
59
|
"3": {
|
|
59
|
-
badge:
|
|
60
|
-
|
|
60
|
+
badge:
|
|
61
|
+
"bg-blue-50 text-blue-700/70 border-blue-700/10 dark:bg-blue-900/30 dark:text-blue-300 dark:border-blue-300/20",
|
|
62
|
+
dot: "bg-blue-700/70 dark:bg-blue-400/80",
|
|
61
63
|
},
|
|
62
64
|
"4": {
|
|
63
|
-
badge:
|
|
64
|
-
|
|
65
|
+
badge:
|
|
66
|
+
"bg-yellow-50 text-yellow-600/80 border-yellow-600/10 dark:bg-yellow-900/30 dark:text-yellow-300 dark:border-yellow-300/20",
|
|
67
|
+
dot: "bg-yellow-500/80 dark:bg-yellow-400/90",
|
|
65
68
|
},
|
|
66
69
|
"5": {
|
|
67
|
-
badge:
|
|
68
|
-
|
|
70
|
+
badge:
|
|
71
|
+
"bg-red-50 text-red-700/70 border-red-700/10 dark:bg-red-900/30 dark:text-red-300 dark:border-red-300/20",
|
|
72
|
+
dot: "bg-red-700/70 dark:bg-red-400/80",
|
|
69
73
|
},
|
|
70
74
|
} as const;
|
|
71
75
|
|
|
@@ -76,25 +80,58 @@ function getStatusCodeClass(statusCode: string, key: "badge" | "dot"): string {
|
|
|
76
80
|
|
|
77
81
|
function buildTokenStyle(token: {
|
|
78
82
|
color?: string;
|
|
83
|
+
darkColor?: string;
|
|
79
84
|
bgColor?: string;
|
|
85
|
+
darkBgColor?: string;
|
|
80
86
|
fontStyle?: number;
|
|
81
87
|
htmlStyle?: Record<string, string>;
|
|
88
|
+
darkHtmlStyle?: Record<string, string>;
|
|
82
89
|
}): string | undefined {
|
|
83
90
|
const styleSegments: string[] = [];
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
const pushStyleVariable = (property: string, value?: string) => {
|
|
93
|
+
if (value) styleSegments.push(`${property}:${value}`);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
pushStyleVariable("--rd-token-color", token.color);
|
|
97
|
+
pushStyleVariable("--rd-token-color-dark", token.darkColor);
|
|
98
|
+
pushStyleVariable("--rd-token-bg", token.bgColor);
|
|
99
|
+
pushStyleVariable("--rd-token-bg-dark", token.darkBgColor);
|
|
87
100
|
|
|
88
101
|
const fontStyle = typeof token.fontStyle === "number" ? token.fontStyle : 0;
|
|
89
102
|
if ((fontStyle & 1) === 1) styleSegments.push("font-style:italic");
|
|
90
103
|
if ((fontStyle & 2) === 2) styleSegments.push("font-weight:600");
|
|
91
104
|
if ((fontStyle & 4) === 4) styleSegments.push("text-decoration:underline");
|
|
92
105
|
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
const pushHtmlStyle = (
|
|
107
|
+
styleObject: Record<string, string> | undefined,
|
|
108
|
+
isDarkStyle: boolean,
|
|
109
|
+
) => {
|
|
110
|
+
if (!styleObject || typeof styleObject !== "object") return;
|
|
111
|
+
|
|
112
|
+
for (const [property, value] of Object.entries(styleObject)) {
|
|
113
|
+
const normalizedProperty = property.trim().toLowerCase();
|
|
114
|
+
if (normalizedProperty === "color") {
|
|
115
|
+
pushStyleVariable(
|
|
116
|
+
isDarkStyle ? "--rd-token-color-dark" : "--rd-token-color",
|
|
117
|
+
value,
|
|
118
|
+
);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (normalizedProperty === "background-color") {
|
|
122
|
+
pushStyleVariable(
|
|
123
|
+
isDarkStyle ? "--rd-token-bg-dark" : "--rd-token-bg",
|
|
124
|
+
value,
|
|
125
|
+
);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
95
129
|
styleSegments.push(`${property}:${value}`);
|
|
96
130
|
}
|
|
97
|
-
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
pushHtmlStyle(token.htmlStyle, false);
|
|
134
|
+
pushHtmlStyle(token.darkHtmlStyle, true);
|
|
98
135
|
|
|
99
136
|
if (!styleSegments.length) return undefined;
|
|
100
137
|
return styleSegments.join(";");
|
|
@@ -139,7 +176,7 @@ async function renderCodeLinesHtml(
|
|
|
139
176
|
const tokenStyleAttribute = tokenStyle
|
|
140
177
|
? ` style="${escapeAttribute(tokenStyle)}"`
|
|
141
178
|
: "";
|
|
142
|
-
return `<span${tokenStyleAttribute}>${escapeHtml(token.content)}</span>`;
|
|
179
|
+
return `<span data-rd-token${tokenStyleAttribute}>${escapeHtml(token.content)}</span>`;
|
|
143
180
|
})
|
|
144
181
|
.join("")
|
|
145
182
|
: fallbackLineContent.length > 0
|
|
@@ -269,10 +306,10 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
269
306
|
>
|
|
270
307
|
<div class="group/prose-code not-prose relative h-full min-h-0 w-full max-w-full min-w-0">
|
|
271
308
|
<div
|
|
272
|
-
class="flex h-full min-h-0 w-full max-w-full min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xs"
|
|
309
|
+
class="flex h-full min-h-0 w-full max-w-full min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xs dark:border-neutral-800 dark:bg-(--rd-code-surface)"
|
|
273
310
|
>
|
|
274
311
|
<div
|
|
275
|
-
class="flex items-center justify-between gap-2 border-b border-neutral-200 rounded-t-xl bg-neutral-50 inset-shadow-sm inset-shadow-neutral-100/80"
|
|
312
|
+
class="flex items-center justify-between gap-2 border-b border-neutral-200 rounded-t-xl bg-neutral-50 inset-shadow-sm inset-shadow-neutral-100/80 dark:border-neutral-800 dark:bg-neutral-900/60 dark:inset-shadow-neutral-900/80"
|
|
276
313
|
>
|
|
277
314
|
{
|
|
278
315
|
hasMultipleResponses ? (
|
|
@@ -283,7 +320,7 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
283
320
|
>
|
|
284
321
|
<div
|
|
285
322
|
aria-hidden="true"
|
|
286
|
-
class="pointer-events-none absolute top-1/2 z-0 h-[28px] -translate-y-1/2 rounded-lg border-[0.5px] border-neutral-200 bg-white shadow-xs transition-[left,width,opacity] duration-200 ease-out"
|
|
323
|
+
class="pointer-events-none absolute top-1/2 z-0 h-[28px] -translate-y-1/2 rounded-lg border-[0.5px] border-neutral-200 bg-white shadow-xs transition-[left,width,opacity] duration-200 ease-out dark:border-neutral-700/70 dark:bg-(--rd-code-surface)"
|
|
287
324
|
x-bind:class="pillVisible ? 'opacity-100' : 'opacity-0'"
|
|
288
325
|
x-bind:style="'left:' + pillLeft + 'px;width:' + pillWidth + 'px;'"
|
|
289
326
|
/>
|
|
@@ -297,7 +334,7 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
297
334
|
x-bind:data-rd-snippet-tab="index"
|
|
298
335
|
x-on:click="select(index)"
|
|
299
336
|
class="relative z-10 inline-flex h-9 items-center gap-2 border-0 bg-transparent px-3 py-1.5 text-xs font-medium transition-colors duration-150 focus:outline-none focus-visible:outline-none cursor-pointer"
|
|
300
|
-
x-bind:class="selected === index ? 'text-
|
|
337
|
+
x-bind:class="selected === index ? 'text-foreground' : 'text-muted-foreground'"
|
|
301
338
|
>
|
|
302
339
|
<span
|
|
303
340
|
class="size-[7px] shrink-0 rounded-full transition-opacity duration-150"
|
|
@@ -309,13 +346,13 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
309
346
|
</div>
|
|
310
347
|
) : (
|
|
311
348
|
<div class="min-w-0 flex-1">
|
|
312
|
-
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-white">
|
|
313
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-white"></div>
|
|
349
|
+
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-white dark:bg-(--rd-code-surface)">
|
|
350
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-white dark:bg-(--rd-code-surface)"></div>
|
|
314
351
|
<CodeTabEdge
|
|
315
352
|
className="pointer-events-none absolute -top-px left-full z-10 h-[calc(100%+2px)]"
|
|
316
353
|
/>
|
|
317
354
|
|
|
318
|
-
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 pl-5 pr-3 py-1.5 text-xs font-medium text-neutral-700">
|
|
355
|
+
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 pl-5 pr-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300">
|
|
319
356
|
<span
|
|
320
357
|
class="size-[7px] shrink-0 rounded-full"
|
|
321
358
|
class:list={[firstResponse.dotClass]}></span>
|
|
@@ -326,15 +363,15 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
326
363
|
)
|
|
327
364
|
}
|
|
328
365
|
|
|
329
|
-
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-white">
|
|
330
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-white"></div>
|
|
366
|
+
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-white dark:bg-(--rd-code-surface)">
|
|
367
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-white dark:bg-(--rd-code-surface)"></div>
|
|
331
368
|
<CodeTabEdge
|
|
332
369
|
className="pointer-events-none absolute -top-px right-full z-10 h-[calc(100%+2px)] rotate-y-180"
|
|
333
370
|
/>
|
|
334
371
|
<button
|
|
335
372
|
x-on:click="copySelected()"
|
|
336
373
|
type="button"
|
|
337
|
-
class="absolute right-2 top-1/2 z-20 inline-flex size-7 -translate-y-1/2 appearance-none items-center justify-center rounded-md border-0 bg-transparent text-neutral-500/80 shadow-none outline-none ring-0 transition-colors duration-150 hover:bg-neutral-50 hover:text-neutral-600 focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 cursor-pointer"
|
|
374
|
+
class="absolute right-2 top-1/2 z-20 inline-flex size-7 -translate-y-1/2 appearance-none items-center justify-center rounded-md border-0 bg-transparent text-neutral-500/80 shadow-none outline-none ring-0 transition-colors duration-150 hover:bg-neutral-50 hover:text-neutral-600 focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 cursor-pointer dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-200"
|
|
338
375
|
aria-label="Copy code"
|
|
339
376
|
>
|
|
340
377
|
<Icon
|
|
@@ -345,7 +382,7 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
345
382
|
/>
|
|
346
383
|
<Icon
|
|
347
384
|
name="lucide:check"
|
|
348
|
-
class="absolute size-3.5 stroke-3 origin-center text-green-700/80 transition-all duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform motion-reduce:transition-none"
|
|
385
|
+
class="absolute size-3.5 stroke-3 origin-center text-green-700/80 transition-all duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform motion-reduce:transition-none dark:text-green-400/90"
|
|
349
386
|
x-bind:class="copied ? 'scale-110 opacity-100 rotate-0' : 'scale-25 opacity-0 rotate-6'"
|
|
350
387
|
aria-hidden="true"
|
|
351
388
|
/>
|
|
@@ -354,16 +391,16 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
354
391
|
</div>
|
|
355
392
|
|
|
356
393
|
<div class="relative min-h-0 min-w-0 flex-1 overflow-hidden rounded-b-xl">
|
|
357
|
-
<div class="relative h-full overflow-auto [scrollbar-width:thin] [scrollbar-color:var(--color-neutral-300)_transparent] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-neutral-300/70 hover:[&::-webkit-scrollbar-thumb]:bg-neutral-300/90">
|
|
358
|
-
<div class="pointer-events-none sticky top-0 z-10 -mb-4 h-4 w-full bg-linear-to-b from-white to-transparent"></div>
|
|
394
|
+
<div class="relative h-full overflow-auto [scrollbar-width:thin] [scrollbar-color:var(--color-neutral-300)_transparent] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-neutral-300/70 hover:[&::-webkit-scrollbar-thumb]:bg-neutral-300/90 dark:[scrollbar-color:var(--color-neutral-700)_transparent] dark:[&::-webkit-scrollbar-thumb]:bg-neutral-700/70 dark:hover:[&::-webkit-scrollbar-thumb]:bg-neutral-700/90">
|
|
395
|
+
<div class="pointer-events-none sticky top-0 z-10 -mb-4 h-4 w-full bg-linear-to-b from-white to-transparent dark:from-(--rd-code-surface)"></div>
|
|
359
396
|
{
|
|
360
397
|
responseSnippetItems.map((snippet, index) => (
|
|
361
398
|
<pre
|
|
362
|
-
class="relative m-0 min-w-full bg-white p-0 text-[13px] leading-6"
|
|
399
|
+
class="relative m-0 min-w-full bg-white p-0 text-[13px] leading-6 dark:bg-(--rd-code-surface)"
|
|
363
400
|
x-show={`selected === ${index}`}
|
|
364
401
|
{...(index !== 0 ? { "x-cloak": true } : {})}
|
|
365
402
|
data-snippet-index={index}
|
|
366
|
-
><code class="block min-w-full py-2.5 font-mono text-neutral-800"><Fragment set:html={snippet.renderedCodeLinesHtml} /></code></pre>
|
|
403
|
+
><code data-rd-code-theme class="block min-w-full py-2.5 font-mono text-neutral-800 dark:text-neutral-200"><Fragment set:html={snippet.renderedCodeLinesHtml} /></code></pre>
|
|
367
404
|
))
|
|
368
405
|
}
|
|
369
406
|
</div>
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import Tag from "../ui/Tag.astro";
|
|
3
|
+
import { buildOpenApiEndpointHref } from "../../lib/utils";
|
|
3
4
|
import { methodColors } from "../../lib/utils";
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
method: string;
|
|
7
8
|
path: string;
|
|
8
9
|
summary?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
tag?: string;
|
|
9
12
|
parentSlug?: string;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
const { method, path: pathStr, summary, parentSlug = "" } = Astro.props;
|
|
15
|
+
const { method, path: pathStr, summary, title, tag, parentSlug = "" } = Astro.props;
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const methodSlug = slugify(method);
|
|
21
|
-
const endpointSlug = pathSlug ? `${pathSlug}-${methodSlug}` : methodSlug;
|
|
22
|
-
const href = parentSlug ? `/${parentSlug}/${endpointSlug}` : `/${endpointSlug}`;
|
|
17
|
+
const normalizedMethod = method.toLowerCase();
|
|
18
|
+
const href = buildOpenApiEndpointHref({
|
|
19
|
+
path: pathStr,
|
|
20
|
+
method: normalizedMethod,
|
|
21
|
+
groupSlug: parentSlug,
|
|
22
|
+
});
|
|
23
23
|
|
|
24
24
|
// Use summary for title, fallback to method + path
|
|
25
|
-
const text = summary || pathStr
|
|
25
|
+
const text = title || summary || `${normalizedMethod.toUpperCase()} ${pathStr}`;
|
|
26
26
|
|
|
27
27
|
// Normalize paths for comparison (remove trailing slashes)
|
|
28
28
|
const currentPath = Astro.url.pathname.replace(/\/$/, "");
|
|
@@ -42,10 +42,13 @@ const isActive = currentPath === targetPath;
|
|
|
42
42
|
<span
|
|
43
43
|
class:list={[
|
|
44
44
|
"px-1 py-px mr-1.5 border rounded-md text-[10px] font-semibold uppercase",
|
|
45
|
-
methodColors[
|
|
45
|
+
methodColors[normalizedMethod] ?? methodColors.get,
|
|
46
46
|
]}
|
|
47
47
|
>
|
|
48
|
-
{
|
|
48
|
+
{normalizedMethod !== "delete" ? normalizedMethod : "del"}
|
|
49
49
|
</span>
|
|
50
|
-
|
|
50
|
+
<div class="flex items-center gap-2 min-w-0">
|
|
51
|
+
<span>{text}</span>
|
|
52
|
+
{tag && <Tag>{tag}</Tag>}
|
|
53
|
+
</div>
|
|
51
54
|
</a>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { NavOpenApiPage } from "../../lib/validation";
|
|
3
|
+
import { loadOpenApiSpec } from "../../lib/validation";
|
|
4
|
+
import { parseOpenApiEndpoint } from "../../lib/utils";
|
|
5
|
+
import SidebarEndpointLink from "./SidebarEndpointLink.astro";
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
item: NavOpenApiPage;
|
|
9
|
+
parentSlug?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { item, parentSlug = "" } = Astro.props;
|
|
13
|
+
|
|
14
|
+
const parsedEndpoint = parseOpenApiEndpoint(item.openapi.endpoint);
|
|
15
|
+
if (!parsedEndpoint) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Invalid OpenAPI endpoint format "${item.openapi.endpoint}". Expected "METHOD /path".`,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const openApiDoc = await loadOpenApiSpec(item.openapi.source);
|
|
22
|
+
const openApiPaths = openApiDoc?.paths ?? {};
|
|
23
|
+
const endpointMethod = parsedEndpoint.method.toLowerCase();
|
|
24
|
+
|
|
25
|
+
let matchedPath: string | null = null;
|
|
26
|
+
let endpointSummary: string | undefined;
|
|
27
|
+
|
|
28
|
+
for (const [pathStr, pathItem] of Object.entries(openApiPaths)) {
|
|
29
|
+
if (!pathItem || typeof pathItem !== "object") continue;
|
|
30
|
+
if (pathStr.toLowerCase() !== parsedEndpoint.path) continue;
|
|
31
|
+
|
|
32
|
+
const operation = (pathItem as any)[endpointMethod];
|
|
33
|
+
if (!operation) continue;
|
|
34
|
+
|
|
35
|
+
matchedPath = pathStr;
|
|
36
|
+
if (typeof operation.summary === "string") {
|
|
37
|
+
endpointSummary = operation.summary;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!matchedPath) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`OpenAPI endpoint "${item.openapi.endpoint}" was not found in source "${item.openapi.source}".`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<SidebarEndpointLink
|
|
50
|
+
method={endpointMethod}
|
|
51
|
+
path={matchedPath}
|
|
52
|
+
summary={endpointSummary}
|
|
53
|
+
title={item.title}
|
|
54
|
+
tag={item.tag}
|
|
55
|
+
parentSlug={parentSlug}
|
|
56
|
+
/>
|
|
@@ -9,6 +9,8 @@ const idPrefix = `code_group_tab_edge_${Math.random().toString(36).slice(2, 9)}`
|
|
|
9
9
|
const mask0Id = `code_group_tab_edge_mask0_${idPrefix}`;
|
|
10
10
|
const path1OutsideMaskId = `code_group_tab_edge_path_1_outside_1_${idPrefix}`;
|
|
11
11
|
const path3OutsideMaskId = `code_group_tab_edge_path_3_outside_2_${idPrefix}`;
|
|
12
|
+
const edgeBackgroundColor = "var(--rd-code-tab-edge-bg, #ffffff)";
|
|
13
|
+
const edgeBorderColor = "var(--rd-code-tab-edge-border, #e5e5e5)";
|
|
12
14
|
---
|
|
13
15
|
|
|
14
16
|
<svg
|
|
@@ -47,10 +49,10 @@ const path3OutsideMaskId = `code_group_tab_edge_path_3_outside_2_${idPrefix}`;
|
|
|
47
49
|
</mask>
|
|
48
50
|
<path
|
|
49
51
|
d="M1 0L8.0783 0C15.772 0 22.7836 4.41324 26.111 11.3501L34.8889 29.6498C38.2164 36.5868 45.228 41 52.9217 41H60H1L1 0Z"
|
|
50
|
-
fill=
|
|
52
|
+
fill={edgeBackgroundColor}></path>
|
|
51
53
|
<path
|
|
52
54
|
d="M1 0V-1H0V0L1 0ZM1 41H0V42H1V41ZM34.8889 29.6498L33.9873 30.0823L34.8889 29.6498ZM26.111 11.3501L27.0127 10.9177L26.111 11.3501ZM1 1H8.0783V-1H1V1ZM60 40H1V42H60V40ZM2 41V0L0 0L0 41H2ZM25.2094 11.7826L33.9873 30.0823L35.7906 29.2174L27.0127 10.9177L25.2094 11.7826ZM52.9217 42H60V40H52.9217V42ZM33.9873 30.0823C37.4811 37.3661 44.8433 42 52.9217 42V40C45.6127 40 38.9517 35.8074 35.7906 29.2174L33.9873 30.0823ZM8.0783 1C15.3873 1 22.0483 5.19257 25.2094 11.7826L27.0127 10.9177C23.5188 3.6339 16.1567 -1 8.0783 -1V1Z"
|
|
53
|
-
fill=
|
|
55
|
+
fill={edgeBorderColor}
|
|
54
56
|
mask={`url(#${path1OutsideMaskId})`}></path>
|
|
55
57
|
</mask>
|
|
56
58
|
<g mask={`url(#${mask0Id})`}>
|
|
@@ -70,10 +72,10 @@ const path3OutsideMaskId = `code_group_tab_edge_path_3_outside_2_${idPrefix}`;
|
|
|
70
72
|
</mask>
|
|
71
73
|
<path
|
|
72
74
|
d="M0 1.02441H7.0783C14.772 1.02441 21.7836 5.43765 25.111 12.3746L33.8889 30.6743C37.2164 37.6112 44.228 42.0244 51.9217 42.0244H59H0L0 1.02441Z"
|
|
73
|
-
fill=
|
|
75
|
+
fill={edgeBackgroundColor}></path>
|
|
74
76
|
<path
|
|
75
77
|
d="M0 1.02441L0 0.0244141H-1V1.02441H0ZM0 42.0244H-1V43.0244H0L0 42.0244ZM33.8889 30.6743L32.9873 31.1068L33.8889 30.6743ZM25.111 12.3746L26.0127 11.9421L25.111 12.3746ZM0 2.02441H7.0783V0.0244141H0L0 2.02441ZM59 41.0244H0L0 43.0244H59V41.0244ZM1 42.0244L1 1.02441H-1L-1 42.0244H1ZM24.2094 12.8071L32.9873 31.1068L34.7906 30.2418L26.0127 11.9421L24.2094 12.8071ZM51.9217 43.0244H59V41.0244H51.9217V43.0244ZM32.9873 31.1068C36.4811 38.3905 43.8433 43.0244 51.9217 43.0244V41.0244C44.6127 41.0244 37.9517 36.8318 34.7906 30.2418L32.9873 31.1068ZM7.0783 2.02441C14.3873 2.02441 21.0483 6.21699 24.2094 12.8071L26.0127 11.9421C22.5188 4.65831 15.1567 0.0244141 7.0783 0.0244141V2.02441Z"
|
|
76
|
-
fill=
|
|
78
|
+
fill={edgeBorderColor}
|
|
77
79
|
mask={`url(#${path3OutsideMaskId})`}></path>
|
|
78
80
|
</g>
|
|
79
81
|
</svg>
|
|
@@ -81,19 +81,19 @@ if (hasMinLength && hasMaxLength) {
|
|
|
81
81
|
{name}
|
|
82
82
|
</h5>
|
|
83
83
|
<code
|
|
84
|
-
class="text-[10px] font-medium text-neutral-500 border border-neutral-200/80 bg-neutral-50 px-1 rounded-sm"
|
|
84
|
+
class="text-[10px] font-medium text-neutral-500 border border-neutral-200/80 bg-neutral-50 px-1 rounded-sm dark:text-neutral-300 dark:border-neutral-700/70 dark:bg-neutral-900/70"
|
|
85
85
|
>{type}</code
|
|
86
86
|
>
|
|
87
87
|
{
|
|
88
88
|
required && (
|
|
89
|
-
<div class="text-red-700/70 bg-red-50 border border-red-700/10 rounded-full px-1.5 text-[10px] font-mono leading-none py-0.5 pb-0.5 font-[450] h-fit">
|
|
89
|
+
<div class="text-red-700/70 bg-red-50 border border-red-700/10 rounded-full px-1.5 text-[10px] font-mono leading-none py-0.5 pb-0.5 font-[450] h-fit dark:text-red-300 dark:bg-red-950/40 dark:border-red-900/40">
|
|
90
90
|
required
|
|
91
91
|
</div>
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
{
|
|
95
95
|
optional && (
|
|
96
|
-
<div class="text-blue-700/70 bg-blue-50 border border-blue-700/10 rounded-full px-1.5 font-mono text-[10px] leading-none py-0.5 pb-0.5 font-[450] h-fit">
|
|
96
|
+
<div class="text-blue-700/70 bg-blue-50 border border-blue-700/10 rounded-full px-1.5 font-mono text-[10px] leading-none py-0.5 pb-0.5 font-[450] h-fit dark:text-blue-300 dark:bg-blue-950/40 dark:border-blue-900/40">
|
|
97
97
|
optional
|
|
98
98
|
</div>
|
|
99
99
|
)
|
|
@@ -103,7 +103,7 @@ if (hasMinLength && hasMaxLength) {
|
|
|
103
103
|
{
|
|
104
104
|
formattedDescription && (
|
|
105
105
|
<div
|
|
106
|
-
class="prose-rules prose-sm! leading-5! text-neutral-500 **:text-neutral-500"
|
|
106
|
+
class="prose-rules prose-sm! leading-5! text-neutral-500 **:text-neutral-500 dark:text-neutral-400 dark:**:text-neutral-400"
|
|
107
107
|
set:html={formattedDescription}
|
|
108
108
|
/>
|
|
109
109
|
)
|
|
@@ -115,7 +115,7 @@ if (hasMinLength && hasMaxLength) {
|
|
|
115
115
|
{enumValues.map((v, i, a) => {
|
|
116
116
|
return (
|
|
117
117
|
<div class="flex">
|
|
118
|
-
<span class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md">
|
|
118
|
+
<span class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md dark:text-neutral-300 dark:border-neutral-700 dark:bg-neutral-900/70">
|
|
119
119
|
<code>{v}</code>
|
|
120
120
|
</span>
|
|
121
121
|
{a.length - 2 === i ? (
|
|
@@ -133,7 +133,7 @@ if (hasMinLength && hasMaxLength) {
|
|
|
133
133
|
numericRangeLabel && (
|
|
134
134
|
<div class="text-sm">
|
|
135
135
|
<span class="font-medium text-xs">Range:</span>
|
|
136
|
-
<code class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md">
|
|
136
|
+
<code class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md dark:text-neutral-300 dark:border-neutral-700 dark:bg-neutral-900/70">
|
|
137
137
|
{numericRangeLabel}
|
|
138
138
|
</code>
|
|
139
139
|
</div>
|
|
@@ -143,7 +143,7 @@ if (hasMinLength && hasMaxLength) {
|
|
|
143
143
|
stringLengthLabel && (
|
|
144
144
|
<div class="text-sm">
|
|
145
145
|
<span class="font-medium text-xs">Length:</span>
|
|
146
|
-
<code class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md">
|
|
146
|
+
<code class="text-[11px] font-medium text-neutral-600 border border-neutral-200 bg-neutral-50 px-1 py-px rounded-md dark:text-neutral-300 dark:border-neutral-700 dark:bg-neutral-900/70">
|
|
147
147
|
{stringLengthLabel}
|
|
148
148
|
</code>
|
|
149
149
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { Icon as AstroIcon } from "astro-icon/components";
|
|
3
|
+
import { resolveStaticAssetUrl } from "../../lib/static-asset-url";
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
6
|
name: string | undefined | null;
|
|
@@ -19,7 +20,7 @@ const isLocal = !isUrl && !isIconify;
|
|
|
19
20
|
// Files from src/content/docs are copied to public root by copyContentAssets plugin
|
|
20
21
|
let src = name;
|
|
21
22
|
if (isLocal) {
|
|
22
|
-
src = name.startsWith("/") ? name : `/${name}
|
|
23
|
+
src = resolveStaticAssetUrl(name.startsWith("/") ? name : `/${name}`);
|
|
23
24
|
}
|
|
24
25
|
---
|
|
25
26
|
|
|
@@ -50,14 +50,14 @@ validateProps(
|
|
|
50
50
|
}`
|
|
51
51
|
x-init="id = (typeof register === 'function') ? register() : Math.random()"
|
|
52
52
|
role="region"
|
|
53
|
-
class="block border-b border-neutral-800/10 last:border-b-0. [&:first-child>h4>button]:pt-0 [&:last-child>div>div]:pb-0"
|
|
53
|
+
class="block border-b border-neutral-800/10 dark:border-neutral-700/50 last:border-b-0. [&:first-child>h4>button]:pt-0 [&:last-child>div>div]:pb-0"
|
|
54
54
|
>
|
|
55
55
|
<h4 class="not-prose">
|
|
56
56
|
<button
|
|
57
57
|
type="button"
|
|
58
58
|
x-on:click="expanded = !expanded"
|
|
59
59
|
:aria-expanded="expanded"
|
|
60
|
-
class="pb-4 pt-4 group flex w-full items-center justify-between gap-2.5 text-left font-medium text-neutral-800"
|
|
60
|
+
class="pb-4 pt-4 group flex w-full items-center justify-between gap-2.5 text-left font-medium text-neutral-800 dark:text-neutral-200"
|
|
61
61
|
>
|
|
62
62
|
{icon && <Icon name={icon} />}
|
|
63
63
|
<span class:list={["flex-1", titleSize && TITLE_SIZE_CLASS[titleSize]]}
|
|
@@ -65,7 +65,7 @@ validateProps(
|
|
|
65
65
|
>
|
|
66
66
|
<Icon
|
|
67
67
|
name="lucide:chevron-down"
|
|
68
|
-
class="size-5 shrink-0 text-neutral-400 group-hover:text-neutral-600 transition duration-200"
|
|
68
|
+
class="size-5 shrink-0 text-neutral-400 group-hover:text-neutral-600 transition duration-200 dark:text-neutral-500 dark:group-hover:text-neutral-300"
|
|
69
69
|
x-bind:class="expanded && 'rotate-180'"
|
|
70
70
|
/>
|
|
71
71
|
</button>
|
|
@@ -23,31 +23,31 @@ const typeDefaults: Record<
|
|
|
23
23
|
warning: {
|
|
24
24
|
icon: warningIcon,
|
|
25
25
|
color: "bg-amber-500",
|
|
26
|
-
iconColor: "text-amber-500",
|
|
26
|
+
iconColor: "text-amber-500 dark:text-amber-400",
|
|
27
27
|
title: "Warning",
|
|
28
28
|
},
|
|
29
29
|
info: {
|
|
30
30
|
icon: infoIcon,
|
|
31
31
|
color: "bg-sky-600/80",
|
|
32
|
-
iconColor: "text-sky-600/80",
|
|
32
|
+
iconColor: "text-sky-600/80 dark:text-sky-400",
|
|
33
33
|
title: "Info",
|
|
34
34
|
},
|
|
35
35
|
tip: {
|
|
36
36
|
icon: lightbulbIcon,
|
|
37
37
|
color: "bg-yellow-500",
|
|
38
|
-
iconColor: "text-yellow-500",
|
|
38
|
+
iconColor: "text-yellow-500 dark:text-yellow-400",
|
|
39
39
|
title: "Tip",
|
|
40
40
|
},
|
|
41
41
|
danger: {
|
|
42
42
|
icon: dangerIcon,
|
|
43
43
|
color: "bg-red-600",
|
|
44
|
-
iconColor: "text-red-600",
|
|
44
|
+
iconColor: "text-red-600 dark:text-red-400",
|
|
45
45
|
title: "Danger",
|
|
46
46
|
},
|
|
47
47
|
success: {
|
|
48
48
|
icon: successIcon,
|
|
49
49
|
color: "bg-green-600",
|
|
50
|
-
iconColor: "text-green-600",
|
|
50
|
+
iconColor: "text-green-600 dark:text-green-400",
|
|
51
51
|
title: "Success",
|
|
52
52
|
},
|
|
53
53
|
};
|
|
@@ -72,7 +72,7 @@ const resolvedTitle = title ?? defaults.title;
|
|
|
72
72
|
|
|
73
73
|
<aside
|
|
74
74
|
class:list={[
|
|
75
|
-
"my-5 space-y-1 rounded-lg border border-neutral-200/80 shadow-xs px-4 py-3.5 pl-6 relative",
|
|
75
|
+
"my-5 space-y-1 rounded-lg border border-neutral-200 bg-white/80 shadow-xs px-4 py-3.5 pl-6 relative dark:border-neutral-800 dark:bg-(--rd-code-surface)",
|
|
76
76
|
]}
|
|
77
77
|
role="note"
|
|
78
78
|
>
|
|
@@ -96,11 +96,11 @@ const resolvedTitle = title ?? defaults.title;
|
|
|
96
96
|
<img src={defaults.icon} alt="" width="16" height="16" class="" />
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
|
-
<h6 class:list={["font-semibold text-sm"]}>
|
|
99
|
+
<h6 class:list={["font-semibold text-sm text-neutral-900 dark:text-neutral-100"]}>
|
|
100
100
|
{resolvedTitle}
|
|
101
101
|
</h6>
|
|
102
102
|
</div>
|
|
103
|
-
<div class="**:first:mt-0! **:last:mb-0! text-sm">
|
|
103
|
+
<div class="**:first:mt-0! **:last:mb-0! text-sm text-neutral-700 dark:text-neutral-300">
|
|
104
104
|
<slot />
|
|
105
105
|
</div>
|
|
106
106
|
</aside>
|