Get the current notes inlinks with DVJS

Language:: JavaScript
Program:: Obsidian
Link:: 2022-12-13-CD-Dataview - Keeping Notes on Beers

Summary

Use Dataview JS to get the current notes inlinks

Code

// ^ (change to dvjs to use)
// Nicely Render all the inlinks to the current note on a single line
// Checks if an alias exists for inlinks and will render the alias
// if it exists
//
let myInlinks = [];
for (let inlink of dv.current().file.inlinks){
	let inlinkFile = dv.page(inlink.path).file
	let displayName = inlinkFile.aliases ? inlinkFile.aliases[0] : inlinkFile.name
	let fileLink = dv.fileLink(inlinkFile.path, false, displayName)
	myInlinks.push(fileLink)
}
let myInlinksStr = `**Inlinks**: \n - ${myInlinks.join('\n-  ')}`
dv.paragraph(myInlinksStr)

Explanation

Result


up:: ๐Ÿงช Code Diary