Skip to content

Commit 8cf11f6

Browse files
committed
Fix Mermaid diagram rendering on View Transitions
Remove conflicting Mermaid re-initialization script that was creating a race condition with astro-mermaid's built-in View Transitions support. The astro-mermaid integration already listens to astro:after-swap and handles diagram re-rendering correctly with proper centering CSS.
1 parent d3f73ee commit 8cf11f6

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

src/layouts/Layout.astro

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,6 @@ const ogImageURL = new URL(ogImage, Astro.site);
130130
headroomInstance.init();
131131
});
132132
</script>
133-
134-
<!-- Re-initialize Mermaid diagrams after View Transitions -->
135-
<script>
136-
import mermaid from 'mermaid';
137-
138-
function initMermaid() {
139-
// Remove data-processed attributes from any previously rendered diagrams
140-
// (prevents Mermaid from skipping them on re-initialization)
141-
const processedDiagrams = document.querySelectorAll('.mermaid[data-processed="true"]');
142-
processedDiagrams.forEach((diagram) => {
143-
diagram.removeAttribute('data-processed');
144-
});
145-
146-
// Re-initialize Mermaid to process all unprocessed diagrams
147-
mermaid.contentLoaded();
148-
}
149-
150-
// Run on initial page load and after every View Transition
151-
document.addEventListener('astro:page-load', initMermaid);
152-
</script>
153133
</head>
154134
<body class="bg-background text-text antialiased">
155135
<!-- Scroll Progress Indicator (long-form content pages only) -->

0 commit comments

Comments
 (0)