mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	refactor(export/share): use different URL rewriting mechanism
This commit is contained in:
		
							parent
							
								
									8523050ab2
								
							
						
					
					
						commit
						77e4c3d0ec
					
				@ -1774,6 +1774,10 @@ class BNote extends AbstractBeccaEntity<BNote> {
 | 
			
		||||
        return this.getVisibleChildNotes().length > 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get shareId() {
 | 
			
		||||
        return this.noteId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default BNote;
 | 
			
		||||
 | 
			
		||||
@ -51,6 +51,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider {
 | 
			
		||||
 | 
			
		||||
        if (note) {
 | 
			
		||||
            content = renderNoteForExport(note, branch, basePath);
 | 
			
		||||
            content = content.replace(/href="[^"]*\.\/([a-zA-Z0-9_\/]{12})[^"]*"/g, "href=\"#root/$1\"");
 | 
			
		||||
            content = this.rewriteFn(content, noteMeta);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -137,7 +137,7 @@ content = content.replaceAll(headingRe, (...match) => {
 | 
			
		||||
                        const action = note.type === "book" ? "getChildNotes" : "getVisibleChildNotes";
 | 
			
		||||
                        for (const childNote of note[action]()) {
 | 
			
		||||
                            const isExternalLink = childNote.hasLabel("shareExternal") || childNote.hasLabel("shareExternalLink");
 | 
			
		||||
                            const linkHref = isExternalLink ? childNote.getLabelValue("shareExternal") ?? childNote.getLabelValue("shareExternalLink") : `./${childNote.shareId ?? "#root/" + childNote.noteId}`;
 | 
			
		||||
                            const linkHref = isExternalLink ? childNote.getLabelValue("shareExternal") ?? childNote.getLabelValue("shareExternalLink") : `./${childNote.shareId}`;
 | 
			
		||||
                            const target = isExternalLink ? ` target="_blank" rel="noopener noreferrer"` : "";
 | 
			
		||||
                        %>
 | 
			
		||||
                            <li>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user