/* eslint-disable no-console */ // const data = `

Trilium  really does rock! Don't believe me? Well this entire website was made using the shared notes feature inside Trilium with a little bit of extra CSS and JS also contained in Trilium.

It turns Trilium into an insanely powerful WYSIWYG website creator. But that's just a side feature of Trilium, it's so much more powerful with endless possibilities.

Why It Rocks

If somehow you aren't already convinced, take a look below for even more reasons why Trilium rocks!

Built-in Features

This section is shamelessly borrowed from Trilium's README.

Community Addons

Nriver maintains an awesome list of addons for Trilium made by the community. Check out the official list on GitHub. We do mirror the list here on the Showcase page if you just want a quick look.

Custom Scripts

In addition to using community made scripts, widgets, themes, and everything in between, Trilium leaves things open-ended for you the end-user. You can script as much or as little as you like inside Trilium. You can automate all kinds of workflows, do data analysis, or even simple things like set a keybind to open a specific note. The world is your oyster as they say, and Trilium is your world. Pretend that made sense.

 

About This Site

This website is not at all affiliated with Trilium Notes or its creator(s). The site is broken up into a few main sections that you can see in the navigation bar at the top of the page. At a high level, there's two sections targeting end-users, two sections targeting developers, and one meant for everyone.

Status

This site is still a work-in-progress! Writing documentation isn't the most fun thing in the world so this will just be something I work on when I have free time. You'll usually find me working on one of my Trilium-related addons, Trilium itself, or my other open-source project: BetterDiscord.

Goals

Rather than saying some specific goals of what this site strives to be, I'll say what it strives not to be; This site is not meant to be a complete recreation of the Wiki with every detail and page included. It is meant to be a (mostly) one-stop shop for users and developers alike looking to supplement their knowledge. It may at some point expand and include everything from the wiki because users tend to prefer a fancier UI like this, but it is not the end-goal.

Contributing

Since this entire site is just a share from my personal Trilium instance, there is no easy way to contribute new pages or fixes for typos. At some point I will create a GitHub repository for this site's supplementary CSS and JS, and that repository can also act as a home for issues and discussion. But who knows, maybe within that time frame I'll think of some clever way to introduce contributions.

 

`; const data = `

Frontend API

The frontend api supports two styles, regular scripts that are run with the current app and note context, and widgets that export an object to Trilium to be used in the UI. In both cases, the frontend api of Trilium is available to scripts running in the frontend context as global variable api. The members and methods of the api can be seen on the FrontendScriptApi page.

Scripts

Scripts don't have any special requirements. They can be run at will using the execute button in the UI or they can be configured to run at certain times using Attributes on the note containing the script.

Global Events

This attribute is called #run and it can have any of the following values:

Entity Events

These events are triggered by certain relations to other notes. Meaning that the script is triggered only if the note has this script attached to it through relations (or it can inherit it).

Widgets

Conversely to scripts, widgets do have some specific requirements in order to work. A widget must:

parentWidget

Tutorial

For more information on building widgets, take a look at Widget Basics.

`; const headingRe = /()(.+?)(<\/h[1-6]>)/g; // const slugify = (text: string) => text.toLowerCase().replace(/[^\w]/g, "-"); // const modified = data2.replaceAll(headingRe, (...match: RegExpMatchArray) => { // match[0] = match[0].replace(match[3], `#${match[3]}`); // return match[0]; // }); // console.log(modified); const headingMatches = [...data.matchAll(headingRe)]; interface ToCEntry { level: number; name: string; children: ToCEntry[]; } const level = (m: RegExpMatchArray) => parseInt(m[1].replace(/[]+/g, "")); const toc: ToCEntry[] = [ { level: level(headingMatches[0]), name: headingMatches[0][2], children: [] } ]; const last = (arr = toc) => arr[arr.length - 1]; const makeEntry = (m: RegExpMatchArray): ToCEntry => ({level: level(m), name: m[2], children: []}); const getLevelArr = (lvl: number, arr = toc): ToCEntry[] => { if (arr[0].level === lvl) return arr; const top = last(arr); return top.children.length ? getLevelArr(lvl, top.children) : top.children; }; for (let m = 1; m < headingMatches.length; m++) { const target = getLevelArr(level(headingMatches[m])); target.push(makeEntry(headingMatches[m])); } console.log(JSON.stringify(toc, null, 4)); // const end = (arr = toc): ToCEntry => { // const top = last(arr); // return top.children.length ? end(top.children) : top; // }; // console.log(end()); // const previousEntry = last(); // if (previousEntry.level === cLvl) { // toc.push(makeEntry(current)); // } // else if (previousEntry.level === cLvl - 1) { // previousEntry.children.push(makeEntry(current)); // } // else if (previousEntry.level < cLvl) { // const target = findParentEntry(previous[2]) ?? end(); // // console.log(previous[2], target, current[2]); // const plvl = level(previous); // if (plvl === cLvl) { // target.children.push(makeEntry(current)); // } // else if (plvl === cLvl - 1) { // const subitem = target.children.find(e => e.name === previous[2])!; // subitem.children.push(makeEntry(current)); // } // } // else if (previousEntry.level > cLvl) { // toc.push(makeEntry(current)); // }