fix(site): more reliable tabs (#153)

This commit is contained in:
Darius Cepulis
2025-11-03 12:44:41 -06:00
committed by GitHub
parent a2c6aaa3c0
commit 8f90083b89
16 changed files with 453 additions and 505 deletions
+2 -8
View File
@@ -2,13 +2,10 @@
* Adapted from https://mdxjs.com/guides/syntax-highlighting/
*
* This plugin:
* 1. Generates stable IDs for <pre> blocks (for tabs)
* 2. Tags <code> children of <pre> blocks so they know they're in a pre block
* 3. Marks <pre> blocks with hasFrame based on whether they're inside a <TabsPanel> JSX component
* 1. Tags <code> children of <pre> blocks so they know they're in a pre block
* 2. Marks <pre> blocks with hasFrame based on whether they're inside a <TabsPanel> JSX component
*/
let preBlockCounter = 0;
export default function rehypePrepareCodeBlocks() {
return (tree) => {
// Process the tree with a stateful visitor
@@ -31,9 +28,6 @@ export default function rehypePrepareCodeBlocks() {
// Mark whether this pre block is inside tabs
node.properties.hasFrame = context.hasFrame;
// Generate stable ID for this pre block
node.properties['data-tabs-id'] = `pre-${preBlockCounter++}`;
// Tag <code> children
node.children.forEach((child) => {
if (child.tagName === 'code') {