Skip to content

Build your personal knowledge base with Trilium Notes

chore(client): load stylesheets

Elian Doran047b5a85d2d1
diff --git a/apps/client/src/desktop.html b/apps/client/src/desktop.html
index 3ad6a96499..334e12d6e8 100644
--- a/apps/client/src/desktop.html
+++ b/apps/client/src/desktop.html
@@ -27,20 +27,52 @@
<!-- Bootstrap (request server for required information) -->
<script>
async function bootstrap() {
+ await setupGlob();
+ await loadStylesheets();
+ await loadScripts();
+ }
+
+ async function setupGlob() {
const response = await fetch("./bootstrap");
const json = await response.json();
global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */
-
window.glob = {
...json,
activeDialog: null
};
+ }
+
+ async function loadStylesheets() {
+ const { assetPath, themeCssUrl, themeUseNextAsBase } = window.glob;
+ const cssToLoad = [];
+ cssToLoad.push(`${assetPath}/stylesheets/theme-light.css`);
+ if (themeCssUrl) {
+ cssToLoad.push(themeCssUrl);
+ }
+ if (themeUseNextAsBase === "next") {
+ cssToLoad.push(`${assetPath}/stylesheets/theme-next.css`)
+ } else if (themeUseNextAsBase === "next-dark") {
+ cssToLoad.push(`${assetPath}/stylesheets/theme-next-dark.css`)
+ } else if (themeUseNextAsBase === "next-light") {
+ cssToLoad.push(`${assetPath}/stylesheets/theme-next-light.css`)
+ }
+ cssToLoad.push(`${assetPath}/stylesheets/style.css`);
+
+ for (const href of cssToLoad) {
+ const linkEl = document.createElement("link");
+ linkEl.href = href;
+ linkEl.rel = "stylesheet";
+ document.body.appendChild(linkEl);
+ }
+ }
- const { assetPath } = json;
+ async function loadScripts() {
+ const assetPath = glob.assetPath;
await import(`./${assetPath}/runtime.js`);
await import(`./${assetPath}/desktop.js`);
}
+
bootstrap();
</script>
diff --git a/apps/server/src/assets/views/desktop.ejs b/apps/server/src/assets/views/desktop.ejs
index a0e395226f..1a81cc883e 100644
--- a/apps/server/src/assets/views/desktop.ejs
+++ b/apps/server/src/assets/views/desktop.ejs
@@ -12,21 +12,6 @@
<link href="<%= assetPath %>/stylesheets/ckeditor-theme.css" rel="stylesheet">
<link href="api/fonts" rel="stylesheet">
-<link href="<%= assetPath %>/stylesheets/theme-light.css" rel="stylesheet">
-
-<% if (themeCssUrl) { %>
-<link href="<%= themeCssUrl %>" rel="stylesheet">
-<% } %>
-
-<% if (themeUseNextAsBase === "next") { %>
- <link href="<%= assetPath %>/stylesheets/theme-next.css" rel="stylesheet">
-<% } else if (themeUseNextAsBase === "next-dark") { %>
- <link href="<%= assetPath %>/stylesheets/theme-next-dark.css" rel="stylesheet">
-<% } else if (themeUseNextAsBase === "next-light") { %>
- <link href="<%= assetPath %>/stylesheets/theme-next-light.css" rel="stylesheet">
-<% } %>
-
-<link href="<%= assetPath %>/stylesheets/style.css" rel="stylesheet">
<script src="<%= appPath %>/desktop.js" crossorigin type="module"></script>