Skip to content

Build your personal knowledge base with Trilium Notes

refactor(share): integrate with client

Elian Doran8bdf3626f0fc
diff --git a/apps/client/package.json b/apps/client/package.json
index 33133da870..8d0d679289 100644
--- a/apps/client/package.json
+++ b/apps/client/package.json
@@ -25,6 +25,7 @@
"@triliumnext/codemirror": "workspace:*",
"@triliumnext/commons": "workspace:*",
"@triliumnext/highlightjs": "workspace:*",
+ "@triliumnext/share-theme": "workspace:*",
"autocomplete.js": "0.38.1",
"bootstrap": "5.3.6",
"boxicons": "2.1.4",
diff --git a/apps/client/src/share.ts b/apps/client/src/share.ts
index 6e221b1f1d..cc688a02ba 100644
--- a/apps/client/src/share.ts
+++ b/apps/client/src/share.ts
@@ -1,5 +1,6 @@
import "normalize.css";
import "@triliumnext/ckeditor5/content.css";
+import "@triliumnext/share-theme/styles/index.css";
/**
* Fetch note with given ID from backend
diff --git a/apps/client/tsconfig.app.json b/apps/client/tsconfig.app.json
index e51437ed11..f9c39c6092 100644
--- a/apps/client/tsconfig.app.json
+++ b/apps/client/tsconfig.app.json
@@ -35,14 +35,17 @@
],
"references": [
{
- "path": "../../packages/highlightjs/tsconfig.lib.json"
+ "path": "../../packages/share-theme"
},
{
- "path": "../../packages/codemirror/tsconfig.lib.json"
+ "path": "../../packages/highlightjs/tsconfig.lib.json"
},
{
"path": "../../packages/commons/tsconfig.lib.json"
},
+ {
+ "path": "../../packages/codemirror/tsconfig.lib.json"
+ },
{
"path": "../../packages/ckeditor5/tsconfig.lib.json"
}
diff --git a/apps/server/package.json b/apps/server/package.json
index 9530f7b112..a056263488 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -252,11 +252,6 @@
"glob": "**/*",
"input": "packages/share-theme/src/templates",
"output": "share-theme/templates"
- },
- {
- "glob": "**/*",
- "input": "packages/share-theme/dist",
- "output": "share-theme/public"
}
]
}
diff --git a/apps/server/src/assets/views/share/page.ejs b/apps/server/src/assets/views/share/page.ejs
index 68d6ca8913..2fba4702bb 100644
--- a/apps/server/src/assets/views/share/page.ejs
+++ b/apps/server/src/assets/views/share/page.ejs
@@ -12,7 +12,11 @@
<% } else { %>
<link rel="shortcut icon" href="../favicon.ico">
<% } %>
- <link href="assets/styles.css" rel="stylesheet">
+ <script src="<%= appPath %>/share.js" type="module"></script>
+ <link href="<%= assetPath %>/src/share.css" rel="stylesheet">
+ <% if (!note.isLabelTruthy("shareOmitDefaultCss")) { %>
+ <link href="<%= assetPath %>/stylesheets/share.css" rel="stylesheet">
+ <% } %>
<% for (const cssRelation of note.getRelations("shareCss")) { %>
<link href="api/notes/<%= cssRelation.value %>/download" rel="stylesheet">
<% } %>
diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts
index c5795e7cf8..c117421329 100644
--- a/apps/server/src/routes/assets.ts
+++ b/apps/server/src/routes/assets.ts
@@ -48,7 +48,6 @@ async function register(app: express.Application) {
app.use(`/assets/vX/stylesheets`, express.static(path.join(srcRoot, "public/stylesheets")));
app.use(`/${assetUrlFragment}/libraries`, persistentCacheStatic(path.join(srcRoot, "public/libraries")));
app.use(`/assets/vX/libraries`, express.static(path.join(srcRoot, "..", "libraries")));
- app.use(`/share/assets`, express.static(path.join(resourceDir, "share-theme", "public")));
}
export default {
diff --git a/packages/share-theme/package.json b/packages/share-theme/package.json
index 6120927658..09c1217dec 100644
--- a/packages/share-theme/package.json
+++ b/packages/share-theme/package.json
@@ -12,6 +12,7 @@
},
"exports": {
"./templates/*": "./src/templates/*",
+ "./styles/*": "./src/styles/*",
"./*": "./dist/*"
},
"author": "",
diff --git a/packages/share-theme/src/templates/page.ejs b/packages/share-theme/src/templates/page.ejs
index 15ba3efd58..b3f8f2d196 100644
--- a/packages/share-theme/src/templates/page.ejs
+++ b/packages/share-theme/src/templates/page.ejs
@@ -11,6 +11,9 @@
<link rel="shortcut icon" href="<% if (note.hasRelation("shareFavicon")) { %>api/notes/<%= note.getRelation("shareFavicon").value %>/download<% } else { %>../favicon.ico<% } %>">
<script src="<%= appPath %>/share.js" type="module"></script>
<link href="../<%= assetPath %>/libraries/normalize.min.css" rel="stylesheet">
+ <% if (!note.isLabelTruthy("shareOmitDefaultCss")) { %>
+ <link href="<%= assetPath %>/stylesheets/share.css" rel="stylesheet">
+ <% } %>
<% if (note.hasLabel("shareSwagger")) { %>
<!-- TODO: make these note IDs customizable -->
@@ -51,15 +54,9 @@ const customServerYml = `- url: "{protocol}://{domain}:{port}/etapi"
<% if (note.type === "text" || note.type === "book") { %>
<link href="../<%= assetPath %>/libraries/ckeditor/ckeditor-content.css" rel="stylesheet">
<% } %>
- <% if (!note.isLabelTruthy("shareOmitDefaultCss")) { %>
- <link href="assets/styles.css" rel="stylesheet">
- <% } %>
<% for (const cssRelation of note.getRelations("shareCss")) { %>
<link href="api/notes/<%= cssRelation.value %>/download" rel="stylesheet">
<% } %>
- <% if (!note.isLabelTruthy("shareOmitDefaultCss")) { %>
- <script type="module" src="assets/scripts.js"></script>
- <% } %>
<% for (const jsRelation of note.getRelations("shareJs")) { %>
<script type="module" src="api/notes/<%= jsRelation.value %>/download"></script>
<% } %>