Skip to content

Commit cb7c72f

Browse files
authored
fix(docs): code block styles (#222)
* fix(docs): add missing languages to code block * fix(docs): code block in light mode * fix(docs): correct indentation inside code blocks * fix(docs): code block overflow
1 parent 775d894 commit cb7c72f

File tree

10 files changed

+821
-818
lines changed

10 files changed

+821
-818
lines changed

apps/docs/components/docs/code-block.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import html from "shiki/langs/html.mjs";
66
import json from "shiki/langs/json.mjs";
77
import jsx from "shiki/langs/jsx.mjs";
88
import markdown from "shiki/langs/markdown.mjs";
9+
import bash from "shiki/langs/bash.mjs";
910
import tsx from "shiki/langs/tsx.mjs";
11+
import http from "shiki/langs/http.mjs";
1012
import githubLight from "shiki/themes/github-light.mjs";
1113
import vesper from "shiki/themes/vesper.mjs";
1214
import { SciFiCard } from "@/components/scifi-card";
@@ -22,7 +24,7 @@ interface CodeBlockProps extends React.ComponentProps<"div"> {
2224

2325
const highlighter = createHighlighterCoreSync({
2426
themes: [vesper, githubLight],
25-
langs: [tsx, jsx, html, css, json, markdown],
27+
langs: [tsx, jsx, html, css, json, markdown, bash, http],
2628
engine: createJavaScriptRegexEngine(),
2729
});
2830

@@ -69,12 +71,12 @@ function CodeBlock({
6971

7072
return (
7173
<SciFiCard
72-
className="group/code relative my-4 w-full overflow-hidden rounded border border-border bg-[#101010] text-sm backdrop-blur-sm transition-all duration-300 hover:border-primary/20"
74+
className="group/code relative my-4 w-full overflow-hidden rounded border border-border bg-muted/50 dark:bg-[#101010] text-sm backdrop-blur-sm transition-all duration-300 hover:border-primary/20"
7375
cornerOpacity="opacity-0 group-hover/code:opacity-100"
7476
variant="primary"
7577
>
7678
{(language !== "text" || filename) && (
77-
<div className="flex items-center justify-between border-white/5 border-b bg-white/5 px-4 py-2.5">
79+
<div className="flex items-center justify-between border-foreground/5 border-b bg-foreground/5 px-4 py-2.5">
7880
<div className="flex items-center gap-3">
7981
{filename && (
8082
<span className="font-medium text-foreground/80 text-xs tracking-tight">
@@ -104,9 +106,9 @@ function CodeBlock({
104106
{highlightedCode ? (
105107
<div
106108
className={cn(
107-
"overflow-x-auto font-mono text-[13px] leading-relaxed",
109+
"font-mono! text-[13px] leading-relaxed",
108110
"[&>pre]:m-0 [&>pre]:overflow-visible [&>pre]:p-4 [&>pre]:leading-relaxed",
109-
"[&>pre>code]:block [&>pre>code]:w-full",
111+
"[&>pre>code]:overflow-x-auto [&>pre>code]:block [&>pre>code]:w-full [&>pre>code]:p-4",
110112
"[&_.line]:min-h-5",
111113
className
112114
)}
@@ -115,7 +117,7 @@ function CodeBlock({
115117
) : (
116118
<pre
117119
className={cn(
118-
"overflow-x-auto p-4 font-mono text-foreground text-sm leading-relaxed",
120+
"overflow-x-auto p-4 font-mono! text-foreground text-sm leading-relaxed",
119121
"[&>code]:block [&>code]:w-full [&>code]:p-0 [&>code]:text-inherit",
120122
className
121123
)}
@@ -133,7 +135,7 @@ function InlineCode({ className, ...props }: React.ComponentProps<"code">) {
133135
return (
134136
<code
135137
className={cn(
136-
"relative rounded border border-accent bg-accent/50 px-1.5 py-0.5 font-medium font-mono text-primary text-sm",
138+
"relative rounded border border-accent bg-accent/50 px-1.5 py-0.5 font-medium font-mono! text-primary text-sm",
137139
className
138140
)}
139141
{...props}

apps/docs/content/docs/api-keys.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ Authentication/authorization failures return structured errors:
9696
<CodeBlock
9797
language="json"
9898
code={`{
99-
"success": false,
100-
"error": "Authentication required",
101-
"code": "AUTH_REQUIRED"
102-
}`}
99+
"success": false,
100+
"error": "Authentication required",
101+
"code": "AUTH_REQUIRED"
102+
}`}
103103
/>
104104

105105
<CodeBlock
106106
language="json"
107107
code={`{
108-
"success": false,
109-
"error": "Insufficient permissions",
110-
"code": "FORBIDDEN"
111-
}`}
108+
"success": false,
109+
"error": "Insufficient permissions",
110+
"code": "FORBIDDEN"
111+
}`}
112112
/>
113113

114114
### Rotation and revocation

0 commit comments

Comments
 (0)