Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(dev): document exporting functionality
Elian Doran444e10304774
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.htmlindex ba74ada3cb..2f3341063e 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.html@@ -31,6 +31,9 @@data-list-item-id="e3995e60b9751ea177ac920a901635d4b">The <code>favicon.ico</code> is not handled automatically, it needs to bemanually added on the server after the export is generated.</li><li data-list-item-id="e72c2a986808ce27eb3bb5001fe4710cb">The “Last updated” for notes is not available.</li>+ <li data-list-item-id="e53e8959701206c7a064ba811c0123bef">The search functionality works slightly different since the normal one+ requires an active API to work. In the static export, search still works+ but uses a different mechanism so results might be different.</li></ul><h2>Differences from normal .zip export</h2><ul>diff --git a/docs/Developer Guide/!!!meta.json b/docs/Developer Guide/!!!meta.jsonindex 1f821d9c07..93338db972 100644--- a/docs/Developer Guide/!!!meta.json+++ b/docs/Developer Guide/!!!meta.json@@ -1717,6 +1717,33 @@"format": "markdown","dataFileName": "Hidden notes.md","attachments": []+ },+ {+ "isClone": false,+ "noteId": "vphziLmQeQHY",+ "notePath": [+ "jdjRLhLV3TtI",+ "wbVIolLKDhe2",+ "vphziLmQeQHY"+ ],+ "title": "Share",+ "notePosition": 260,+ "prefix": null,+ "isExpanded": false,+ "type": "text",+ "mime": "text/html",+ "attributes": [+ {+ "type": "label",+ "name": "iconClass",+ "value": "bx bx-share-alt",+ "isInheritable": false,+ "position": 10+ }+ ],+ "format": "markdown",+ "dataFileName": "Share.md",+ "attachments": []}]},diff --git a/docs/Developer Guide/Developer Guide/Development and architecture/Share.md b/docs/Developer Guide/Developer Guide/Development and architecture/Share.mdnew file mode 100644index 0000000000..22dc512f58--- /dev/null+++ b/docs/Developer Guide/Developer Guide/Development and architecture/Share.md@@ -0,0 +1,30 @@+# Share+## Share theme++The share theme represents the layout, styles and scripts behind the Share notes functionality. The current implementation is a heavy adaptation of [trilium.rocks](https://trilium.rocks/) which is a third-party share theme.++* The theme resides in `packages/share-theme`.+* The HTML is defined in `src/templates` using EJS templating.+* The `src/scripts` and `src/styles` subdirectories house the rest of the theme.++## Building the share theme++* In `packages/share-theme`, run `pnpm build` to trigger a build. This will generate `dist` which will then be used by the server.+* Alternatively, use `pnpm dev` to watch for changes.++## Integration with the server for the share functionality++The server renders the templates using EJS templating from the share theme and hosts the assets.++* In dev mode, the templates and assets are served directly from `packages/share-theme/dist`.+ * Modifications to the assets (scripts or styles) will reflect without having to restart the server. However the share theme needs to be built first (see previous section).+ * Changes to the template will require a restart of the server, since they are cached. Simply press Enter in the console with `pnpm server:start` to quickly trigger a restart.+* In production mode, the share theme is automatically built by the server build script and copied to `dist/share-theme`.++The server route handling this functionality is in `src/share/routes.ts`.++## Exporting to static HTML files++This functionality is also handled by the server, but in `src/services/export/zip/share_theme` instead. It works quite similar to the normal sharing functionality, but it uses `BNote` instead of `SNote` (and so on for other entity types), in order to work regardless of whether a note is shared or not.++The same templates are used and rendered by the server, except that they are stored in a file instead of served to web clients.\ No newline at end of filediff --git a/docs/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.md b/docs/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.mdindex fab4e35f00..38453563f2 100644--- a/docs/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.md+++ b/docs/User Guide/User Guide/Advanced Usage/Sharing/Exporting HTML for web publish.md@@ -17,6 +17,7 @@ Apart from normal <a class="reference-link" href="../Sharing.md">Sharing</a>, e* The URL structure is different. Where in normal sharing it's something along the way of `example.com/share/noteid`, the notes follow an hierarchical structure, such as `docs.triliumnotes.org/user-guide/concepts/navigation/tree-concepts`.* The `favicon.ico` is not handled automatically, it needs to be manually added on the server after the export is generated.* The “Last updated” for notes is not available.+* The search functionality works slightly different since the normal one requires an active API to work. In the static export, search still works but uses a different mechanism so results might be different.## Differences from normal .zip export