mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 16:49:58 +01:00
Rename main to scripts
This commit is contained in:
19
src/scripts/fixes/externallinks.ts
Normal file
19
src/scripts/fixes/externallinks.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* This function just lets us map some note links to be external links.
|
||||
* This was originally designed to link the Trilium GitHub via a note.
|
||||
*/
|
||||
export default function addExternalLinks(mapping: Record<string, string>) {
|
||||
for (const id in mapping) {
|
||||
const links = document.querySelectorAll<HTMLAnchorElement>(`a[href*="${id}"]`);
|
||||
if (!links.length) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`Could not find link to note id ${id}`);
|
||||
continue;
|
||||
}
|
||||
for (const link of links) {
|
||||
link.href = mapping[id];
|
||||
link.target = "_blank";
|
||||
link.rel = "noopener noreferrer";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user