Skip to content

Commit

Permalink
Make code block not focusable as they wrap instead of scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Dec 7, 2024
1 parent a4ad2ca commit 5036541
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
8 changes: 8 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export default defineConfig({
theme,
// Removes `style` attribute from <pre>
keepBackground: false,
// Make code block not focusable as they wrap instead of scrolling
transformers: [
{
pre(node) {
node.properties.tabindex = undefined;
},
},
],
},
],
rehypeSlug,
Expand Down
30 changes: 11 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"richtypo": "^7.0.1",
"romanize": "^1.1.1",
"sanitize-html": "^2.13.1",
"shiki": "^1.22.0",
"shiki": "^1.24.0",
"strip-json-comments": "^5.0.1",
"tamia": "^7.1.6",
"unist-util-visit": "^5.0.0"
Expand Down
2 changes: 2 additions & 0 deletions src/util/highlightCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ export function highlightCode(code: string, lang: CodeLang, theme: CodeTheme) {
return highlighter.codeToHtml(code, {
lang,
theme: theme === 'light' ? 'Squirrelsong Light' : 'Squirrelsong Dark',
// Make code block not focusable as they wrap instead of scrolling
tabindex: false,
});
}

0 comments on commit 5036541

Please sign in to comment.