const fieldName = "theme"; // Your field with linksconst oldPrefix = "Thoughts/01 Themes/";const newPrefix = "Digital Garden/Topics/";const relatedLinks = dv.current()[fieldName];if (Array.isArray(relatedLinks)) { // Map over the links, replace the path, and output only clickable links dv.el("span", relatedLinks .map(link => { if (link && link.path) { let newPath = link.path.startsWith(oldPrefix) ? link.path.replace(oldPrefix, newPrefix) : link.path; return dv.fileLink(newPath); } }) .filter(Boolean).join(", ") // Remove any undefined/null items );} else { dv.el(dv.current().theme);}
Remark
simple functions can be written as a complex linear combination of finitely many indicator functions.
Proof
Suppose ϕ:E→C is a simple function where the range ϕ(E)={a1,a2,…,an}. Define the sets
Ai=ϕ−1({ai})
Note that each Ai is measurable because they are intersections of the measurable sets where Re(ϕ)=Re(ai) and Im(ϕ)=Im(ai).
For all i=j we have Ai∩Aj=∅ and ⋃i=1nAi=E. ie, the Ai form a finite partition of the domain E. Thus, for all x∈E, we can write
ϕ(x)=∑i=1nai⋅1Ai(x)
Which is a finite complex linear combination of indicator functions.
\tag*{$\blacksquare$}