mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 08:15:52 +01:00
switching themes via loading only specific CSS
This commit is contained in:
@@ -19,7 +19,7 @@ function index(req, res) {
|
||||
|
||||
res.render(view, {
|
||||
csrfToken: csrfToken,
|
||||
theme: options.theme,
|
||||
themeCssUrl: getThemeCssUrl(options.theme),
|
||||
headingStyle: options.headingStyle,
|
||||
mainFontSize: parseInt(options.mainFontSize),
|
||||
treeFontSize: parseInt(options.treeFontSize),
|
||||
@@ -36,8 +36,28 @@ function index(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function getThemeCssUrl(theme) {
|
||||
if (theme === 'light') {
|
||||
return false; // light theme is always loaded as baseline
|
||||
}
|
||||
|
||||
if (theme === 'dark') {
|
||||
return `stylesheets/theme-dark.css`;
|
||||
}
|
||||
else {
|
||||
const themeNote = attributeService.getNoteWithLabel('appTheme', theme);
|
||||
|
||||
if (themeNote) {
|
||||
return `api/notes/download/${themeNote.noteId}`;
|
||||
}
|
||||
else {
|
||||
return false; // baseline light theme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getAppCssNoteIds() {
|
||||
return attributeService.getNoteIdsWithLabels(['appCss', 'appTheme']);
|
||||
return attributeService.getNotesWithLabel('appCss').map(note => note.noteId);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user