mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	docs(dev): document exporting functionality
	
		
			
	
		
	
	
		
	
		
			Some checks are pending
		
		
	
	
		
			
				
	
				Checks / main (push) Waiting to run
				
			
		
			
				
	
				CodeQL Advanced / Analyze (actions) (push) Waiting to run
				
			
		
			
				
	
				CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
				
			
		
			
				
	
				Deploy Documentation / Build and Deploy Documentation (push) Waiting to run
				
			
		
			
				
	
				Dev / Test development (push) Waiting to run
				
			
		
			
				
	
				Dev / Build Docker image (push) Blocked by required conditions
				
			
		
			
				
	
				Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
				
			
		
			
				
	
				Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
				
			
		
			
				
	
				/ Check Docker build (Dockerfile) (push) Waiting to run
				
			
		
			
				
	
				/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
				
			
		
			
				
	
				/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
				
			
		
			
				
	
				/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
				
			
		
			
				
	
				/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
				
			
		
			
				
	
				/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
				
			
		
			
				
	
				/ Merge manifest lists (push) Blocked by required conditions
				
			
		
			
				
	
				playwright / main (push) Waiting to run
				
			
		
		
	
	
				
					
				
			
		
			Some checks are pending
		
		
	
	Checks / main (push) Waiting to run
				
			CodeQL Advanced / Analyze (actions) (push) Waiting to run
				
			CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
				
			Deploy Documentation / Build and Deploy Documentation (push) Waiting to run
				
			Dev / Test development (push) Waiting to run
				
			Dev / Build Docker image (push) Blocked by required conditions
				
			Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
				
			Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
				
			/ Check Docker build (Dockerfile) (push) Waiting to run
				
			/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
				
			/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
				
			/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
				
			/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
				
			/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
				
			/ Merge manifest lists (push) Blocked by required conditions
				
			playwright / main (push) Waiting to run
				
			This commit is contained in:
		
							parent
							
								
									1d6ab64ae5
								
							
						
					
					
						commit
						444e103047
					
				@ -31,6 +31,9 @@
 | 
			
		||||
  data-list-item-id="e3995e60b9751ea177ac920a901635d4b">The <code>favicon.ico</code> is not handled automatically, it needs to be
 | 
			
		||||
    manually 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>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								docs/Developer Guide/!!!meta.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								docs/Developer Guide/!!!meta.json
									
									
									
									
										vendored
									
									
								
							@ -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": []
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										30
									
								
								docs/Developer Guide/Developer Guide/Development and architecture/Share.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								docs/Developer Guide/Developer Guide/Development and architecture/Share.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -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.
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user