# Beskrivning # Logg ```dataviewjs const fmt = d => d ? moment(d.toString()).format("DD-MM-YYYY") : ""; const currentFile = dv.current().file; const currentNote = currentFile.name.replace(/\.md$/, ""); const currentPath = currentFile.path.replace(/\.md$/, ""); const sessionNotes = dv.pages() .filter(p => p.file.folder?.split("/").includes("Sessions") && p.file.outlinks.some(l => l.path.replace(/\.md$/, "") === currentPath)); function extractNumber(n) { return Number(n.match(/\d+$/)?.[0] || 0); } const sorted = [...sessionNotes] .sort((a, b) => extractNumber(b.file.name) - extractNumber(a.file.name)); if (!sorted.length) { dv.paragraph("> No backlinks found in sessions."); } else { const linkRegex = new RegExp( `\\[\\[${currentNote.replace(/[-\/\\^$*+?.()|[\]{}]/g,'\\amp;')}(?:#[^\\]]*)?(?:\\|[^\\]]+)?\\]\\]`); for (const note of sorted) { const raw = await dv.io.load(note.file.path); const body = raw.replace(/^---[\s\S]*?^---\s*/m, ''); const loc = note.Location ? note.Location.map(l => `[[${l}]]`).join(", ") : ""; const dt = fmt(note.Date); for (const ln of body.split("\n")) { if (linkRegex.test(ln)) { dv.paragraph( `> <span style="display:inline-block;max-width:calc(100% - 8rem);">${ln}</span>` + `<span style="float:right;text-align:right;font-size:0.9em;line-height:1.2;white-space:nowrap;">` + `${note.file.link}<br>${loc}${loc && dt ? ' · ' : ''}${dt}</span>`); } } } } ``` # Nämnd i %% DATAVIEW_PUBLISHER: start ```dataviewjs const currentPath = file.path.replace(/\.md$/, ""); // Get session notes that link to the current note const sessionNotes = dv.pages() .filter(p => p.file.folder?.split("/").includes("Sessions") && p.file.outlinks.some(l => l.path.replace(/\.md$/, "") === currentPath)); if (!sessionNotes.length) { "> No backlinks found in sessions."; } else { // Sort by session number const sorted = sessionNotes .sort(p => { const match = p.file.name.match(/\d+$/); return match ? parseInt(match[0]) : 0; }, 'desc'); let output = ""; for (const note of sorted) { // Embed the Sammanställning section from each session output += `## [[${note.file.name}]]\n`; output += `![[${note.file.name}#Sammanfattning]]\n\n`; } output; } ``` %% ## [[Session 157]] ![[Session 157#Sammanfattning]] ## [[Session 156]] ![[Session 156#Sammanfattning]] %% DATAVIEW_PUBLISHER: end %%