mirror of
https://github.com/zadam/trilium.git
synced 2026-01-02 20:54:24 +01:00
fix(icon_packs): integrate boxicons back into share theme
This commit is contained in:
parent
61e96f91d0
commit
841cb32835
@ -1,9 +1,10 @@
|
||||
import { assetUrlFragment } from "../services/asset_path.js";
|
||||
import path from "path";
|
||||
import express from "express";
|
||||
import { getResourceDir, isDev } from "../services/utils.js";
|
||||
import type serveStatic from "serve-static";
|
||||
import { existsSync } from "fs";
|
||||
import path from "path";
|
||||
import type serveStatic from "serve-static";
|
||||
|
||||
import { assetUrlFragment } from "../services/asset_path.js";
|
||||
import { getResourceDir, isDev } from "../services/utils.js";
|
||||
|
||||
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => {
|
||||
if (!isDev) {
|
||||
@ -31,19 +32,24 @@ async function register(app: express.Application) {
|
||||
css: { devSourcemap: true }
|
||||
});
|
||||
app.use(`/${assetUrlFragment}/`, (req, res, next) => {
|
||||
req.url = `/${assetUrlFragment}` + req.url;
|
||||
req.url = `/${assetUrlFragment}${req.url}`;
|
||||
vite.middlewares(req, res, next);
|
||||
});
|
||||
app.use(`/share/assets/fonts/`, (req, res, next) => {
|
||||
req.url = `/${assetUrlFragment}/src/fonts${req.url}`;
|
||||
vite.middlewares(req, res, next);
|
||||
});
|
||||
app.use(`/node_modules/@excalidraw/excalidraw/dist/prod`, persistentCacheStatic(path.join(srcRoot, "../../node_modules/@excalidraw/excalidraw/dist/prod")));
|
||||
} else {
|
||||
const publicDir = path.join(resourceDir, "public");
|
||||
if (!existsSync(publicDir)) {
|
||||
throw new Error("Public directory is missing at: " + path.resolve(publicDir));
|
||||
throw new Error(`Public directory is missing at: ${ path.resolve(publicDir)}`);
|
||||
}
|
||||
|
||||
app.use(`/${assetUrlFragment}/src`, persistentCacheStatic(path.join(publicDir, "src")));
|
||||
app.use(`/${assetUrlFragment}/stylesheets`, persistentCacheStatic(path.join(publicDir, "stylesheets")));
|
||||
app.use(`/${assetUrlFragment}/fonts`, persistentCacheStatic(path.join(publicDir, "fonts")));
|
||||
app.use(`/share/assets/fonts/`, express.static(path.join(publicDir, "fonts")));
|
||||
app.use(`/${assetUrlFragment}/translations/`, persistentCacheStatic(path.join(publicDir, "translations")));
|
||||
app.use(`/node_modules/`, persistentCacheStatic(path.join(publicDir, "node_modules")));
|
||||
}
|
||||
@ -59,10 +65,9 @@ export function getShareThemeAssetDir() {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
const srcRoot = path.join(__dirname, "..", "..");
|
||||
return path.join(srcRoot, "../../packages/share-theme/dist");
|
||||
} else {
|
||||
const resourceDir = getResourceDir();
|
||||
return path.join(resourceDir, "share-theme/assets");
|
||||
}
|
||||
const resourceDir = getResourceDir();
|
||||
return path.join(resourceDir, "share-theme/assets");
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@ -130,7 +130,7 @@ export function renderNoteContent(note: SNote) {
|
||||
|
||||
const customLogoId = note.getRelation("shareLogo")?.value;
|
||||
const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png` : `../${assetUrlFragment}/images/icon-color.svg`;
|
||||
const iconPacks = getIconPacks().filter(p => !!shaca.notes[p.manifestNoteId]);
|
||||
const iconPacks = getIconPacks().filter(p => p.builtin || !!shaca.notes[p.manifestNoteId]);
|
||||
|
||||
return renderNoteContentInternal(note, {
|
||||
subRoot,
|
||||
@ -141,7 +141,10 @@ export function renderNoteContent(note: SNote) {
|
||||
ancestors,
|
||||
isStatic: false,
|
||||
faviconUrl: note.hasRelation("shareFavicon") ? `api/notes/${note.getRelationValue("shareFavicon")}/download` : `../favicon.ico`,
|
||||
iconPackCss: iconPacks.map(p => generateCss(p, `/share/api/attachments/${p.fontAttachmentId}/download`))
|
||||
iconPackCss: iconPacks.map(p => generateCss(p, p.builtin
|
||||
? `/share/assets/fonts/${p.fontAttachmentId}.${MIME_TO_EXTENSION_MAPPINGS[p.fontMime]}`
|
||||
: `/share/api/attachments/${p.fontAttachmentId}/download`
|
||||
))
|
||||
.filter(Boolean)
|
||||
.join("\n\n"),
|
||||
iconPackSupportedPrefixes: iconPacks.map(p => p.manifest.prefix)
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"boxicons": "2.1.4",
|
||||
"fuse.js": "7.1.0",
|
||||
"katex": "0.16.27",
|
||||
"mermaid": "11.12.2"
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
@import "boxicons/css/boxicons.min.css";
|
||||
|
||||
@import "./base.css";
|
||||
@import "./childlinks.css";
|
||||
@import "./externallinks.css";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user