Since I am a heavy user of backlinks in my workflow, I quickly needed code that previews their content.
It was easy to do, just with the following code:
// USER CONDITIONS ==============================================================
let EXCLUDE_DATAVIEW_FILES = true;
// ==============================================================================
var inlinks = Array.from(dv.current().file.inlinks);
var flippedInlinks = inlinks.reverse();
var text_print;
var excludeFolder = ["👨‍💻Automations", "🔎 Traceability of literature reading"];
var excludeFilesWithNamesStartingWith = ["datav"]; // DO NOT ADD "datav"!
var notesToGiveOnlyLinks = ["REPORT PLOTS"]
let L_excl_folder = excludeFolder.length;
let L_notesToGiveOnlyLinks = notesToGiveOnlyLinks.length;
if (EXCLUDE_DATAVIEW_FILES) {
excludeFilesWithNamesStartingWith.push("datav");
} else {
// Check if "datav" exists in the array and remove it if found
const index = excludeFilesWithNamesStartingWith.indexOf("datav");
if (index !== -1) {
excludeFilesWithNamesStartingWith.splice(index, 1);
}
}
for (let p of flippedInlinks) { // Loop through pages
let ppath = p.path;
let excludeNote = false;
let showOnlyLink = false;
// Check if the note's path contains an excluded folder
for (let iFolder = 0; iFolder < L_excl_folder; iFolder++) {
if (ppath.includes(excludeFolder[iFolder])) {
excludeNote = true;
break; // No need to check further, exclude the note
}
}
if (!excludeNote) {
// Check if the note's name starts with any excluded string
for (let iFileName = 0; iFileName < excludeFilesWithNamesStartingWith.length; iFileName++) {
if (ppath.startsWith(excludeFilesWithNamesStartingWith[iFileName])) {
excludeNote = true;
break; // No need to check further, exclude the note
}
}
if (!excludeNote) {
dv.header("5", p);
for (let iFile = 0; iFile < L_notesToGiveOnlyLinks; iFile++) {
if (ppath.includes(notesToGiveOnlyLinks[iFile])) {
showOnlyLink = true;
break; // No need to check further, exclude the note
}
}
if (!showOnlyLink) {
dv.el("article", await dv.io.load(ppath));
dv.el("article", "---");
}
}
}
}
However, this previews them only with one column. I wanted something that previews them with many columns.
See the video of the result in this google drive link.
Code is quite large, and given in this repo.