Rename main to scripts

This commit is contained in:
Zack Rauen
2023-09-27 16:28:08 -04:00
parent 2ae6d4c5a4
commit 667cd64f3b
12 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
/**
* 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.
*
* TODO: make it fix aliases too
*/
export default function fixActiveLink(aliases: Record<string, string>) {
const active = document.querySelector("#menu strong");
if (!active) return; // Something is really wrong
// Currently active note id is stored on body
const id = document.body.dataset.noteId!;
const href = aliases[id] ?? id;
// Create the new link
const link = document.createElement("a");
link.className = "type-text active";
link.href = ``;
link.textContent = active.textContent;
link.href = `./${href}`;
// Replace the <strong>
active.replaceWith(link);
}