Files
Trilium/src/main/fixes/activelink.ts

24 lines
760 B
TypeScript
Raw Normal View History

2023-09-22 23:57:17 -04:00
/**
* For some reason Trilium share chooses to have the
* active link be just a <strong> rather than a true
* link with a special style. This fixes that and
* turns the <strong> back into an actual link
* with the correct note id.
*/
2023-09-21 03:18:11 -04:00
export default function fixActiveLink() {
const active = document.querySelector("#menu strong");
if (!active) return; // Something is really wrong
2023-09-22 23:57:17 -04:00
// Currently active note id is stored on body
const id = document.body.dataset.noteId;
// Create the new link
2023-09-21 03:18:11 -04:00
const link = document.createElement("a");
link.className = "type-text active";
link.href = ``;
link.textContent = active.textContent;
link.href = `./${id}`;
2023-09-22 23:57:17 -04:00
// Replace the <strong>
active.replaceWith(link);
2023-09-21 03:18:11 -04:00
}