diff --git a/src/routes/index.ts b/src/routes/index.ts index c5c29797c..658a47796 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 baseline return 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 theme return false; diff --git a/src/views/desktop.ejs b/src/views/desktop.ejs index 2de4a1817..da48eb497 100644 --- a/src/views/desktop.ejs +++ b/src/views/desktop.ejs @@ -76,6 +76,10 @@ <% } %> +<% if (themeUseNextAsBase) { %> + +<% } %> +