Notes/src/main/index.ts

85 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-09-22 23:57:17 -04:00
/* eslint-disable no-console */
import fixActiveLink from "./fixes/activelink";
import fixTableHeaders from "./fixes/tableheaders";
import highlight from "./other/highlight";
import buildSidenav from "./navigation/sidenav";
import buildBreadcrumbs from "./navigation/breadcrumbs";
import fixSubMenu from "./fixes/submenu";
import generateTOC from "./navigation/toc";
import addExternalLinks from "./fixes/externallinks";
import injectSwagger from "./other/swagger";
2023-09-23 02:56:59 -04:00
import makeMobileMenu from "./other/mobile";
2023-09-20 03:38:55 -04:00
2023-09-21 03:18:11 -04:00
// https://instance-name/api/notes/vW1cXaYNN7OM/download
2023-09-20 03:38:55 -04:00
2023-09-22 23:57:17 -04:00
const EXTERNAL_LINKS = {
EGFtX8Uw96FQ: "https://github.com/zadam/trilium"
};
2023-09-20 03:38:55 -04:00
2023-09-22 23:57:17 -04:00
function $try<T extends (...a: unknown[]) => unknown>(func: T, ...args: Parameters<T>) {
try {
func.apply(func, args);
}
catch (e) {
console.error(e);
}
}
2023-09-20 03:38:55 -04:00
2023-09-22 23:57:17 -04:00
// const $try = (func, ...args) => {
// try {
// func.apply()
// }
// };
2023-09-23 02:56:59 -04:00
2023-09-22 23:57:17 -04:00
// Perform fixes first
$try(fixActiveLink);
$try(fixTableHeaders);
$try(fixSubMenu);
$try(addExternalLinks, EXTERNAL_LINKS);
// Now layout changes
$try(buildBreadcrumbs);
$try(buildSidenav);
$try(generateTOC);
// Finally, other features
$try(highlight);
$try(injectSwagger);
2023-09-23 02:56:59 -04:00
$try(makeMobileMenu);
// mobileMenu.append(document.querySelector("#menu > ul")!);
// mobileMenu.append(document.querySelector("#sidebar")!);
2023-09-22 23:57:17 -04:00
// try {fixActiveLink();}
// catch (e) {console.error(e);}
// try {highlight();}
// catch (e) {console.error(e);}
// try {fixTableHeaders();}
// catch (e) {console.error(e);}
// try{addLogo();}
// catch{}
// try {fixSubMenu();}
// catch (e) {console.error(e);}
// try {buildSidenav();}
// catch (e) {console.error(e);}
// try {buildBreadcrumbs();}
// catch (e) {console.error(e);}
// try {generateTOC();}
// catch (e) {console.error(e);}
// try {addExternalLinks(EXTERNAL_LINKS);}
// catch (e) {console.error(e);}