mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import type { Request } from "express";
|
|
|
|
import becca from "../../becca/becca.js";
|
|
import markdownService from "../../services/import/markdown.js";
|
|
|
|
function getIconUsage() {
|
|
const iconClassToCountMap: Record<string, number> = {};
|
|
|
|
for (const { value: iconClass, noteId } of becca.findAttributes("label", "iconClass")) {
|
|
if (noteId.startsWith("_")) {
|
|
continue; // ignore icons of "system" notes since they were not set by the user
|
|
}
|
|
|
|
if (!iconClass?.trim()) {
|
|
continue;
|
|
}
|
|
|
|
for (const clazz of iconClass.trim().split(/\s+/)) {
|
|
if (clazz === "bx") {
|
|
continue;
|
|
}
|
|
|
|
iconClassToCountMap[clazz] = (iconClassToCountMap[clazz] || 0) + 1;
|
|
}
|
|
}
|
|
|
|
return { iconClassToCountMap };
|
|
}
|
|
|
|
function renderMarkdown(req: Request) {
|
|
const { markdownContent } = req.body;
|
|
|
|
return {
|
|
htmlContent: markdownService.renderToHtml(markdownContent, "")
|
|
};
|
|
}
|
|
|
|
export default {
|
|
getIconUsage,
|
|
renderMarkdown
|
|
};
|