mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(docs-edit): minify meta JSON (429 KB gain)
This commit is contained in:
parent
c9dba8c0e7
commit
fe7650f6ce
@ -152,10 +152,11 @@ async function exportData(noteId: string, format: "html" | "markdown", outputPat
|
||||
}
|
||||
}
|
||||
|
||||
await cleanUpMeta(outputPath);
|
||||
const minifyMeta = (format === "html");
|
||||
await cleanUpMeta(outputPath, minifyMeta);
|
||||
}
|
||||
|
||||
async function cleanUpMeta(outputPath: string) {
|
||||
async function cleanUpMeta(outputPath: string, minify: boolean) {
|
||||
const metaPath = path.join(outputPath, "!!!meta.json");
|
||||
const meta = JSON.parse(await fs.readFile(metaPath, "utf-8")) as NoteMetaFile;
|
||||
for (const file of meta.files) {
|
||||
@ -171,7 +172,8 @@ async function cleanUpMeta(outputPath: string) {
|
||||
el.isExpanded = false;
|
||||
}
|
||||
|
||||
await fs.writeFile(metaPath, JSON.stringify(meta, null, 4));
|
||||
const json = minify ? JSON.stringify(meta) : JSON.stringify(meta, null, 4);
|
||||
await fs.writeFile(metaPath, json);
|
||||
}
|
||||
|
||||
async function registerHandlers() {
|
||||
|
11140
src/public/app/doc_notes/en/User Guide/!!!meta.json
generated
11140
src/public/app/doc_notes/en/User Guide/!!!meta.json
generated
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user