Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(theme): allow using next as base theme
Elian Doranb2b41edd612d
diff --git a/src/routes/index.ts b/src/routes/index.tsindex c5c29797c7..658a47796a 100644--- a/src/routes/index.ts+++ b/src/routes/index.ts@@ -12,6 +12,7 @@ import packageJson from "../../package.json" with { type: "json" };import assetPath from "../services/asset_path.js";import appPath from "../services/app_path.js";import { Request, Response } from 'express';+import BNote from "../becca/entities/bnote.js";function index(req: Request, res: Response) {const options = optionService.getOptionMap();@@ -28,10 +29,14 @@ function index(req: Request, res: Response) {// The page is restored from cache, but the API call fail.res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");+ const theme = options.theme;+ const themeNote = attributeService.getNoteWithLabel('appTheme', theme);+const isElectron = utils.isElectron();res.render(view, {csrfToken: csrfToken,- themeCssUrl: getThemeCssUrl(options.theme),+ themeCssUrl: getThemeCssUrl(theme, themeNote),+ themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") === "next",headingStyle: options.headingStyle,layoutOrientation: options.layoutOrientation,platform: process.platform,@@ -55,7 +60,7 @@ function index(req: Request, res: Response) {});}-function getThemeCssUrl(theme: string) {+function getThemeCssUrl(theme: string, themeNote: BNote | null) {if (theme === 'light') {// light theme is always loaded as baselinereturn false;@@ -63,11 +68,8 @@ function getThemeCssUrl(theme: string) {return `${assetPath}/stylesheets/theme-dark.css`;} else if (theme === "next") {return `${assetPath}/stylesheets/theme-next.css`;- } else if (!process.env.TRILIUM_SAFE_MODE) {- const themeNote = attributeService.getNoteWithLabel('appTheme', theme);- if (themeNote) {- return `api/notes/download/${themeNote.noteId}`;- }+ } else if (!process.env.TRILIUM_SAFE_MODE && themeNote) {+ return `api/notes/download/${themeNote.noteId}`;} else {// baseline light themereturn false;diff --git a/src/views/desktop.ejs b/src/views/desktop.ejsindex 2de4a1817a..da48eb4972 100644--- a/src/views/desktop.ejs+++ b/src/views/desktop.ejs@@ -76,6 +76,10 @@<link href="<%= themeCssUrl %>" rel="stylesheet"><% } %>+<% if (themeUseNextAsBase) { %>+<link href="<%= assetPath %>/stylesheets/theme-next.css" rel="stylesheet">+<% } %>+<link href="<%= assetPath %>/stylesheets/style.css" rel="stylesheet"><script>