mirror of
https://github.com/zadam/trilium.git
synced 2025-10-31 19:49:01 +01:00
feat(export/zip): load script as well
This commit is contained in:
parent
d3115e834a
commit
01beebf660
@ -562,6 +562,7 @@ ${markdownContent}`;
|
||||
|
||||
const assets = [
|
||||
"style.css",
|
||||
"script.js",
|
||||
"boxicons.css",
|
||||
"boxicons.eot",
|
||||
"boxicons.woff2",
|
||||
@ -654,6 +655,8 @@ function getShareThemeAssets(nameWithExtension: string) {
|
||||
// Rename share.css to style.css.
|
||||
if (nameWithExtension === "style.css") {
|
||||
nameWithExtension = "share.css";
|
||||
} else if (nameWithExtension === "script.js") {
|
||||
nameWithExtension = "share.js";
|
||||
}
|
||||
|
||||
let path: string | undefined;
|
||||
|
||||
@ -17,6 +17,7 @@ import { join } from "path";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
const shareAdjustedAssetPath = isDev ? assetPath : `../${assetPath}`;
|
||||
const shareAdjustedAppPath = isDev ? app_path : `../${app_path}`;
|
||||
|
||||
/**
|
||||
* Represents the output of the content renderer.
|
||||
@ -73,6 +74,9 @@ export function renderNoteForExport(note: BNote, parentBranch: BBranch, basePath
|
||||
`${basePath}style.css`,
|
||||
`${basePath}boxicons.css`
|
||||
],
|
||||
jsToLoad: [
|
||||
`${basePath}script.js`
|
||||
],
|
||||
logoUrl: `${basePath}icon-color.svg`
|
||||
});
|
||||
}
|
||||
@ -86,12 +90,18 @@ export function renderNoteContent(note: SNote) {
|
||||
cssToLoad.push(`${shareAdjustedAssetPath}/src/share.css`);
|
||||
cssToLoad.push(`${shareAdjustedAssetPath}/src/boxicons.css`);
|
||||
}
|
||||
|
||||
// Support custom CSS too.
|
||||
for (const cssRelation of note.getRelations("shareCss")) {
|
||||
cssToLoad.push(`api/notes/${cssRelation.value}/download`);
|
||||
}
|
||||
|
||||
// Determine JS to load.
|
||||
const jsToLoad: string[] = [
|
||||
`${shareAdjustedAppPath}/share.js`
|
||||
];
|
||||
for (const jsRelation of note.getRelations("shareJs")) {
|
||||
jsToLoad.push(`api/notes/${jsRelation.value}/download`);
|
||||
}
|
||||
|
||||
const customLogoId = note.getRelation("shareLogo")?.value;
|
||||
const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png` : `../${assetUrlFragment}/images/icon-color.svg`;
|
||||
|
||||
@ -99,6 +109,7 @@ export function renderNoteContent(note: SNote) {
|
||||
subRoot,
|
||||
rootNoteId: "_share",
|
||||
cssToLoad,
|
||||
jsToLoad,
|
||||
logoUrl
|
||||
});
|
||||
}
|
||||
@ -107,6 +118,7 @@ interface RenderArgs {
|
||||
subRoot: Subroot;
|
||||
rootNoteId: string;
|
||||
cssToLoad: string[];
|
||||
jsToLoad: string[];
|
||||
logoUrl: string;
|
||||
}
|
||||
|
||||
@ -120,7 +132,7 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
|
||||
isEmpty,
|
||||
assetPath: shareAdjustedAssetPath,
|
||||
assetUrlFragment,
|
||||
appPath: isDev ? app_path : `../${app_path}`,
|
||||
appPath: shareAdjustedAppPath,
|
||||
showLoginInShareTheme,
|
||||
t,
|
||||
isDev,
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
<% for (const url of cssToLoad) { %>
|
||||
<link href="<%= url %>" rel="stylesheet">
|
||||
<% } %>
|
||||
<% for (const jsRelation of note.getRelations("shareJs")) { %>
|
||||
<script type="module" src="api/notes/<%= jsRelation.value %>/download"></script>
|
||||
<% for (const url of jsToLoad) { %>
|
||||
<script type="module" src="<%= url %>"></script>
|
||||
<% } %>
|
||||
<% if (note.hasLabel("shareDisallowRobotIndexing")) { %>
|
||||
<meta name="robots" content="noindex,follow" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user