Accessing Backlink Display Text

What I’m trying to do

I am using the templater plugin and it is working fine or as designed to. Below is the code from my template, found somewhere in the forums during my searching.

<%*
let title = tp.file.title;
if (title.startsWith(‘Untitled’)) {
await tp.file.rename(${title} + “-” + tp.date.now(“YYYYMMDDHHmmss”));
} else {
await tp.file.rename(${title} + “-” + tp.date.now(“YYYYMMDDHHmmss”));
}
%>

So, when I create a new file the template to activate and rename the file to whatever the code is telling it to do.

In this instance I am creating the file from links similar to the below

[[S111| Creating a resource hierarchy]]

The format of the links always follows the pattern of: [[Snnn| Custom Display Text]]. However, there is an undesirable side effect of my code in that the title of my note is:

Snnn.

I would rather want it to be

Custom Display Text

Things I have tried

Tried to see if there was a way to access the backlinks data as it displays both the file name and Custom Display Text. But I was unable to find anything useful.

Also, I’m not even sure something like this is possible.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.