mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-30 11:23:39 +00:00
Fix incorrect theme resolution
This commit is contained in:
parent
805b649030
commit
09be21bc9e
|
|
@ -68,7 +68,11 @@ export function MastodonThemes(): Plugin {
|
||||||
// Rewrite the URL to the entrypoint if it matches a theme.
|
// Rewrite the URL to the entrypoint if it matches a theme.
|
||||||
if (isThemeFile(req.url ?? '', themes)) {
|
if (isThemeFile(req.url ?? '', themes)) {
|
||||||
const themeName = pathToThemeName(req.url ?? '');
|
const themeName = pathToThemeName(req.url ?? '');
|
||||||
req.url = `/packs-dev/${themes[areThemeTokensEnabled() ? `${themeName}_theme_tokens` : themeName]}`;
|
const themePath = `/packs-dev/${themes[themeName]}`;
|
||||||
|
const isThemeTokenRequest = req.url.includes('_theme_tokens');
|
||||||
|
req.url = isThemeTokenRequest
|
||||||
|
? themePath.replace('styles/', 'styles_new/')
|
||||||
|
: themePath;
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
@ -156,7 +160,7 @@ async function loadThemesFromConfig(root: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pathToThemeName(file: string) {
|
function pathToThemeName(file: string) {
|
||||||
const basename = path.basename(file);
|
const basename = path.basename(file.replace('_theme_tokens', ''));
|
||||||
return basename.split(/[.?]/)[0] ?? '';
|
return basename.split(/[.?]/)[0] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,12 +169,11 @@ function isThemeFile(file: string, themes: Themes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const basename = pathToThemeName(file.replace('_theme_tokens', ''));
|
const basename = pathToThemeName(file);
|
||||||
return basename in themes;
|
return basename in themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function areThemeTokensEnabled() {
|
function areThemeTokensEnabled() {
|
||||||
// Read the ENV at plugin initialization time
|
|
||||||
const raw = process.env.EXPERIMENTAL_FEATURES ?? '';
|
const raw = process.env.EXPERIMENTAL_FEATURES ?? '';
|
||||||
const features = raw
|
const features = raw
|
||||||
.split(',')
|
.split(',')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user