2023-09-22 23:57:17 -04:00
|
|
|
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";
|
2023-09-23 07:21:38 -04:00
|
|
|
import fixSubMenus from "./fixes/submenu";
|
2023-09-22 23:57:17 -04:00
|
|
|
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-23 07:21:38 -04:00
|
|
|
const ETAPI_REF_NOTE_ID = "pPIXi0uwF5GX";
|
|
|
|
const HIDDEN_SUBMENUS = ["blog"];
|
2023-09-22 23:57:17 -04:00
|
|
|
const EXTERNAL_LINKS = {
|
2023-09-23 07:21:38 -04:00
|
|
|
EGFtX8Uw96FQ: "https://github.com/zadam/trilium",
|
2023-09-23 22:39:38 -04:00
|
|
|
dXAKFE0fJtom: "https://discord.gg/eTaTXUgcBr"
|
2023-09-23 07:21:38 -04:00
|
|
|
};
|
|
|
|
const ALIASES = {
|
|
|
|
WqBnya4Ye8rS: "",
|
|
|
|
ZapIU17QNEyU: "blog"
|
2023-09-22 23:57:17 -04:00
|
|
|
};
|
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) {
|
2023-09-23 07:21:38 -04:00
|
|
|
console.error(e); // eslint-disable-line no-console
|
2023-09-22 23:57:17 -04:00
|
|
|
}
|
|
|
|
}
|
2023-09-20 03:38:55 -04:00
|
|
|
|
2023-09-23 07:21:38 -04:00
|
|
|
/**
|
|
|
|
* Lots of these functions seem to depend on each other indirectly
|
|
|
|
* through DOM changes or classes or what-have-you. This is
|
|
|
|
* obviously not ideal as it makes things less clear, and also
|
|
|
|
* makes TypeScript less helpful.
|
|
|
|
*
|
|
|
|
* TODO: Find a good way of restructuring that allows things
|
|
|
|
* to act a bit more harmoniously.
|
|
|
|
*
|
|
|
|
* TODO: Make use of esbuild's define api to enable a debug
|
|
|
|
* build that contains all the console logs and such.
|
|
|
|
*/
|
2023-09-23 02:56:59 -04:00
|
|
|
|
2023-09-22 23:57:17 -04:00
|
|
|
// Perform fixes first
|
2023-09-23 07:21:38 -04:00
|
|
|
$try(fixActiveLink, ALIASES);
|
2023-09-22 23:57:17 -04:00
|
|
|
$try(fixTableHeaders);
|
2023-09-23 07:21:38 -04:00
|
|
|
$try(fixSubMenus, HIDDEN_SUBMENUS);
|
2023-09-22 23:57:17 -04:00
|
|
|
$try(addExternalLinks, EXTERNAL_LINKS);
|
|
|
|
|
|
|
|
// Now layout changes
|
|
|
|
$try(buildBreadcrumbs);
|
|
|
|
$try(buildSidenav);
|
|
|
|
$try(generateTOC);
|
|
|
|
|
|
|
|
// Finally, other features
|
|
|
|
$try(highlight);
|
2023-09-23 07:21:38 -04:00
|
|
|
$try(injectSwagger, ETAPI_REF_NOTE_ID);
|
2023-09-23 02:56:59 -04:00
|
|
|
$try(makeMobileMenu);
|
2023-09-23 22:39:38 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This was removed because both the title change and the opengraph
|
|
|
|
* additions are now handled by a traefik plugin that rewrites
|
|
|
|
* the body of the http request, that way the change does not
|
|
|
|
* require client-side JS. This is important for sites wishing
|
|
|
|
* to display that information.
|
|
|
|
*
|
|
|
|
* TODO: Determine how reasonable it would be to move more
|
|
|
|
* of these modules over to a traefik rewrite plugin. This gives
|
|
|
|
* a better experience to end users, SEO, etc.
|
|
|
|
*/
|
|
|
|
// $try(addOpenGraphMeta);
|