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
Merge remote-tracking branch 'origin/main' into claude/standalone-shared-notes-ojp5x2
Claudeb66501d8a38e
diff --cc docs/Developer Guide/Developer Guide/Concepts/Share.mdindex a7f59fd7bc,4d08e1d7e7..d635331e0b--- a/docs/Developer Guide/Developer Guide/Concepts/Share.md+++ b/docs/Developer Guide/Developer Guide/Concepts/Share.md@@@ -11,23 -11,10 +11,26 @@@ The share theme represents the layout,* 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.+ * `pnpm dist` is the same build, minified. It is what the app builds run, so a release ships the minified assets while local development keeps readable ones.++ Both scripts clear `dist` first, since esbuild writes into it without removing what an earlier build left there — a minified release build would otherwise be copied alongside the unminified files `pnpm install` produces. A `--module=` build (`build-scripts`, `build-styles`) builds one entry point and deliberately does not clear, so it leaves the other's output alone.+## Where the code lives++The share subsystem is in `packages/trilium-core/src/share`, so that every runtime that carries core can serve it:++* `shaca` is the read-only cache of the `_share` subtree, loaded from raw rows.+* `content_renderer.ts` renders one of its notes into a page.+* `handlers.ts` holds the routes as transport-neutral handlers: each takes a `ShareRequest` and returns a `ShareReply` (status, headers, body or redirect), touching no Express type. `route_paths.ts` lists the URL patterns on their own, free of imports, so a router can register them without loading the renderer behind them.++What differs per platform goes through the `ShareProvider` (`share_provider.ts`): where the rows come from, where the EJS templates come from, and whether a note is allowed to supply its own template.++| | Server / desktop | Standalone / mobile |+| --- | --- | --- |+| Rows | a second, read-only `better-sqlite3` connection (`apps/server/src/share/sql.ts`) | the one sqlite-wasm connection, shared with every other route |+| Templates | read from disk | bundled into the build with `?raw` |+| A note's own EJS template | allowed when backend scripting is enabled | never — this build has no backend scripting |+## Integration with the server for the share functionalityThe server renders the templates using EJS templating from the share theme and hosts the assets.