Skip to content

Conversation

@PawiX25
Copy link
Contributor

@PawiX25 PawiX25 commented Feb 8, 2026

Fix for #167: Code formatting breaks on logo hover

Problem

When hovering over the SeaQL logo in the navbar, Docusaurus prefetches the homepage JS bundle. The HomepageExample.js files in SeaORM, SeaQuery, SeaStreamer, and SeaORM-X all import a standalone prism-core instance and set it as window.Prism at module scope:

import Prism from 'prismjs/components/prism-core';
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-rust");

When this module-level code executes during prefetch, it overwrites the global window.Prism with a bare-bones prism-core instance, corrupting the syntax highlighting state that Docusaurus theme had already configured. This causes code blocks on the current page to lose their formatting and collapse to a single line.

Root Cause

  • The Highlight component from prism-react-renderer (used in these files) already has its own internal Prism instance and does not use window.Prism
  • Rust grammar is already registered via docusaurus.config.js (additionalLanguages: ['toml', 'rust', 'bash']) in all sub-projects
  • The manual prism-core imports were redundant and only served to pollute the global scope

Fix

Remove the 3 problematic lines from all 4 HomepageExample.js files. The Highlight component continues to work correctly using Docusaurus built-in Prism language registration.

Files Changed

  • SeaORM/src/components/HomepageExample.js
  • SeaQuery/src/components/HomepageExample.js
  • SeaStreamer/src/components/HomepageExample.js
  • SeaORM-X/src/components/HomepageExample.js

Testing

  • Build succeeds with no errors
  • Syntax highlighting present in built HTML
  • No window.Prism pollution in the output JS bundles
  • Rust grammar still loaded via Docusaurus built-in additionalLanguages
  • Verified locally: hovering over logo no longer breaks code formatting on docs pages
  • Homepage code examples retain Rust syntax highlighting

Closes #167

…n logo hover (SeaQL#167)

The HomepageExample.js files in SeaORM, SeaQuery, SeaStreamer, and SeaORM-X
imported a standalone prism-core instance and set it as window.Prism at module
scope. When Docusaurus prefetched the homepage bundle (triggered by hovering
over the navbar logo), this module-level code executed and overwrote the global
Prism instance, corrupting syntax highlighting on the current page.

Since Rust grammar is already registered via docusaurus.config.js
(additionalLanguages: ['toml', 'rust', 'bash']), these manual imports were
redundant and harmful. Removing them fixes the issue.

Closes SeaQL#167
@tyt2y3
Copy link
Member

tyt2y3 commented Feb 8, 2026

thank you! I don't think I can reproduce that on chromium, let me try firefox

@tyt2y3
Copy link
Member

tyt2y3 commented Feb 8, 2026

I can reproduce it! thank you again

@tyt2y3 tyt2y3 merged commit 77e3adb into SeaQL:master Feb 8, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code formatting breaks on logo hover

2 participants