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