mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-24 15:06:38 +00:00
Downloading the latest build of GStreamer-rs from its CI job and running a script to embed the rustoc generated documentation into hotdoc based one. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8317>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
function syncThemeWithHotdoc() {
|
|
// Get the current stylesheet
|
|
const currentStyle = document.querySelector('link[rel="stylesheet"][href*="frontend"]');
|
|
if (!currentStyle) return;
|
|
|
|
// Check if we're using dark theme in hotdoc
|
|
const isDark = getActiveStyleSheet() == 'dark';
|
|
|
|
// Use rustdoc's switchTheme function to set the theme
|
|
let newThemeName = isDark ? 'dark' : 'light';
|
|
window.switchTheme(newThemeName, true);
|
|
}
|
|
|
|
// Run on page load
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
localStorage.setItem("rustdoc-use-system-theme", false);
|
|
syncThemeWithHotdoc();
|
|
|
|
// Watch for theme changes in hotdoc
|
|
const theme_observer = new MutationObserver((mutations) => {
|
|
mutations.forEach((mutation) => {
|
|
if (mutation.type === 'attributes' && mutation.attributeName === 'disabled') {
|
|
syncThemeWithHotdoc();
|
|
}
|
|
});
|
|
});
|
|
|
|
// Start observing theme changes
|
|
const styleLink = document.querySelector('link[rel="stylesheet"][href*="frontend"]');
|
|
if (styleLink) {
|
|
theme_observer.observe(styleLink, { attributes: true });
|
|
}
|
|
});
|
|
|