Skip to content

Build your personal knowledge base with Trilium Notes

feat(in-app-help): render documentation

Elian Doran7c34a6178a92
diff --git a/src/public/app/widgets/type_widgets/doc.ts b/src/public/app/widgets/type_widgets/doc.ts
index 433abccda5..431af3d3be 100644
--- a/src/public/app/widgets/type_widgets/doc.ts
+++ b/src/public/app/widgets/type_widgets/doc.ts
@@ -39,7 +39,8 @@ export default class DocTypeWidget extends TypeWidget {
if (docName) {
// find doc based on language
const lng = i18next.language;
- this.$content.load(`${window.glob.appPath}/doc_notes/${lng}/${docName}.html`, (response, status) => {
+ const url = `${window.glob.appPath}/doc_notes/${lng}/${docName}.html`.replaceAll(" ", "%20");
+ this.$content.load(url, (response, status) => {
// fallback to english doc if no translation available
if (status === "error") {
this.$content.load(`${window.glob.appPath}/doc_notes/en/${docName}.html`);
diff --git a/src/services/in_app_help.ts b/src/services/in_app_help.ts
index 2991d0dc05..803fb57dd6 100644
--- a/src/services/in_app_help.ts
+++ b/src/services/in_app_help.ts
@@ -26,21 +26,36 @@ function parseNoteMetaFile(noteMetaFile: NoteMetaFile): HiddenSubtreeItem[] {
return [];
}
- const metaRoot = parseNoteMeta(noteMetaFile.files[0]);
- return metaRoot.children ?? [];
+ const metaRoot = noteMetaFile.files[0];
+ const parsedMetaRoot = parseNoteMeta(metaRoot, "/" + (metaRoot.dirFileName ?? ""));
+ console.log(JSON.stringify(parsedMetaRoot, null, 4));
+ return parsedMetaRoot.children ?? [];
}
-function parseNoteMeta(noteMeta: NoteMeta): HiddenSubtreeItem {
+function parseNoteMeta(noteMeta: NoteMeta, docNameRoot: string): HiddenSubtreeItem {
const item: HiddenSubtreeItem = {
id: `_help_${noteMeta.noteId}`,
title: noteMeta.title,
- type: "doc"
+ type: "doc",
+ attributes: []
};
+ // Handle text notes
+ if (noteMeta.type === "text" && noteMeta.dataFileName) {
+ const docPath = `${docNameRoot}/${path.basename(noteMeta.dataFileName, ".html")}`
+ .substring(1);
+ item.attributes?.push({
+ type: "label",
+ name: "docName",
+ value: docPath
+ });
+ }
+
if (noteMeta.children) {
const children: HiddenSubtreeItem[] = [];
for (const childMeta of noteMeta.children) {
- children.push(parseNoteMeta(childMeta));
+ let newDocNameRoot = (noteMeta.dirFileName ? `${docNameRoot}/${noteMeta.dirFileName}` : docNameRoot);
+ children.push(parseNoteMeta(childMeta, newDocNameRoot));
}
item.children = children;