Skip to content

Commit c0c98b8

Browse files
committed
feat(web): render <kbd> elements in docs
Enable raw HTML in the markdown pipeline and style <kbd> to match the coss Kbd component.
1 parent 1816fdf commit c0c98b8

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

web/bun.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"react-day-picker": "^10.0.1",
2121
"react-dom": "19.2.4",
2222
"rehype-pretty-code": "^0.14.3",
23+
"rehype-raw": "^7.0.0",
2324
"rehype-slug": "^6.0.0",
2425
"rehype-stringify": "^10.0.1",
2526
"remark-gfm": "^4.0.1",

web/src/app/globals.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,26 @@ code[data-theme*=" "] span {
272272
.prose :where(code):not(:where([data-theme], pre *))::after {
273273
content: none;
274274
}
275+
/* coss Kbd look for <kbd> inside docs prose */
276+
.prose kbd {
277+
display: inline-flex;
278+
height: 1.25rem;
279+
min-width: 1.25rem;
280+
align-items: center;
281+
justify-content: center;
282+
gap: 0.25rem;
283+
border-radius: 0.25rem;
284+
background-color: var(--muted);
285+
padding: 0 0.3rem;
286+
font-family: var(--font-sans, ui-sans-serif);
287+
font-size: 0.75rem;
288+
font-weight: 500;
289+
line-height: 1;
290+
color: var(--muted-foreground);
291+
vertical-align: middle;
292+
box-shadow: none;
293+
}
294+
.prose kbd::before,
295+
.prose kbd::after {
296+
content: none;
297+
}

web/src/lib/docs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { unified } from "unified";
44
import remarkParse from "remark-parse";
55
import remarkGfm from "remark-gfm";
66
import remarkRehype from "remark-rehype";
7+
import rehypeRaw from "rehype-raw";
78
import rehypeSlug from "rehype-slug";
89
import rehypePrettyCode from "rehype-pretty-code";
910
import rehypeStringify from "rehype-stringify";
@@ -16,7 +17,8 @@ const CONTENT_DIR = path.join(process.cwd(), "content");
1617
const processor = unified()
1718
.use(remarkParse)
1819
.use(remarkGfm)
19-
.use(remarkRehype)
20+
.use(remarkRehype, { allowDangerousHtml: true })
21+
.use(rehypeRaw)
2022
.use(rehypeSlug)
2123
.use(rehypePrettyCode, {
2224
theme: { light: "github-light", dark: "github-dark" },

0 commit comments

Comments
 (0)