-
Notifications
You must be signed in to change notification settings - Fork 713
Add automatic mermaid theme switching for dark mode #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for toha-ci ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: hossainemruz <[email protected]>
Co-authored-by: hossainemruz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Device | URL |
|---|---|
| desktop | https://6913e1e80228130008e79c84--toha-ci.netlify.app |
| Device | URL |
|---|---|
| mobile | https://6913e1e80228130008e79c84--toha-ci.netlify.app |
| Device | URL |
|---|---|
| desktop | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/ |
| Device | URL |
|---|---|
| mobile | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/ |
| Device | URL |
|---|---|
| desktop | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/markdown-sample/ |
| Device | URL |
|---|---|
| mobile | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/markdown-sample/ |
| Device | URL |
|---|---|
| desktop | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/shortcodes/ |
| Device | URL |
|---|---|
| mobile | https://6913e1e80228130008e79c84--toha-ci.netlify.app/posts/shortcodes/ |
Not what you expected? Are your scores flaky? GitHub runners could be the cause.
Try running on Foo instead
|
@copilot After this change, if I enable the mermaid suppot by You can re-produce by following this setps:
|
…nder Co-authored-by: hossainemruz <[email protected]>
Fixed in commit 5d0c60f. The issue was that original diagram content was being stored after mermaid had already rendered it, causing re-renders to fail. Now the original content is stored before the first render, allowing theme changes to work correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Device | URL |
|---|---|
| desktop | https://6913eb77589ce50008df1afc--toha-ci.netlify.app |
| Device | URL |
|---|---|
| mobile | https://6913eb77589ce50008df1afc--toha-ci.netlify.app |
| Device | URL |
|---|---|
| desktop | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/ |
| Device | URL |
|---|---|
| mobile | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/ |
| Device | URL |
|---|---|
| desktop | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/markdown-sample/ |
| Device | URL |
|---|---|
| mobile | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/markdown-sample/ |
| Device | URL |
|---|---|
| desktop | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/shortcodes/ |
| Device | URL |
|---|---|
| mobile | https://6913eb77589ce50008df1afc--toha-ci.netlify.app/posts/shortcodes/ |
Not what you expected? Are your scores flaky? GitHub runners could be the cause.
Try running on Foo instead
Implementation Complete: Automatic Mermaid Dark Theme Support
mermaid.jsto support dynamic theme switching based on site themethemeanddarkThemeconfiguration options in hugo.yamlSummary
This implementation solves the issue where mermaid diagrams were unreadable in dark theme. Diagrams now automatically switch between light and dark themes as users toggle the site theme.
Bug Fix Applied
Fixed critical bug where mermaid was trying to re-render already processed SVG/HTML content. The fix ensures original diagram content is stored BEFORE the first render, not after.
Changes:
storeOriginalContent()function to capture original diagram text before renderingstoreOriginalContent()beforeinitializeMermaid()on page loadHow It Works
data-original-contentattributeTesting
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.