mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
fix(site): more reliable tabs (#153)
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user