mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-24 01:17:46 +01:00
This PR matches GitHub's behavior more closely on how to render Markdown images in light/dark mode. Images with source suffix `#gh-dark-mode-only` / `#gh-light-mode-only` will only show when the correct theme is requested. Closes: #35545 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
16 lines
606 B
TypeScript
16 lines
606 B
TypeScript
import './polyfills.ts';
|
|
import './relative-time.ts';
|
|
import './origin-url.ts';
|
|
import './overflow-menu.ts';
|
|
import {isDarkTheme} from '../utils.ts';
|
|
|
|
function initPageThemeDarkLight() {
|
|
// Set page's theme color preference as early as possible, to avoid flicker of wrong theme color during page load.
|
|
const sync = () => document.documentElement.setAttribute('data-gitea-theme-dark', String(isDarkTheme()));
|
|
sync();
|
|
// Track system theme changes in case Gitea is using "auto" theme.
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', sync);
|
|
}
|
|
|
|
initPageThemeDarkLight();
|