Stop loading settings on every single page index
parent
26a7cd83c6
commit
73e5bb6672
|
@ -67,13 +67,13 @@ export async function parseIndexTextRepublish({ name, text }: IndexEvent) {
|
|||
const parsed = await markdown.parseMarkdown(text);
|
||||
|
||||
if (isTemplate(text)) {
|
||||
console.log("Indexing", name, "as template");
|
||||
// console.log("Indexing", name, "as template");
|
||||
await events.dispatchEvent("page:indexTemplate", {
|
||||
name,
|
||||
tree: parsed,
|
||||
});
|
||||
} else {
|
||||
console.log("Indexing", name, "as page");
|
||||
// console.log("Indexing", name, "as page");
|
||||
await events.dispatchEvent("page:index", {
|
||||
name,
|
||||
tree: parsed,
|
||||
|
|
|
@ -10,16 +10,27 @@ export type StyleObject = ObjectValue<{
|
|||
origin: string;
|
||||
}>;
|
||||
|
||||
let customStylePages: string[] = [];
|
||||
let lastCustomStyleRead: number | null = null;
|
||||
|
||||
export async function indexSpaceStyle({ name, tree }: IndexTreeEvent) {
|
||||
const allStyles: StyleObject[] = [];
|
||||
|
||||
// Also collect CSS from custom styles in settings
|
||||
let customStylePages = await readSetting("customStyles", []);
|
||||
if (!Array.isArray(customStylePages)) {
|
||||
customStylePages = [customStylePages];
|
||||
// Cache the setting for 10s
|
||||
if (
|
||||
lastCustomStyleRead === null || Date.now() > lastCustomStyleRead + 10000
|
||||
) {
|
||||
customStylePages = await readSetting("customStyles", []);
|
||||
lastCustomStyleRead = Date.now();
|
||||
if (!Array.isArray(customStylePages)) {
|
||||
customStylePages = [customStylePages];
|
||||
}
|
||||
customStylePages = customStylePages.map((page: string) =>
|
||||
cleanPageRef(page)
|
||||
);
|
||||
}
|
||||
customStylePages = customStylePages.map((page: string) => cleanPageRef(page));
|
||||
|
||||
// Also collect CSS from custom styles in settings
|
||||
collectNodesOfType(tree, "FencedCode").map((t) => {
|
||||
const codeInfoNode = findNodeOfType(t, "CodeInfo");
|
||||
if (!codeInfoNode) {
|
||||
|
|
Loading…
Reference in New Issue