lets just save it

This commit is contained in:
taskylizard 2023-10-28 17:52:08 +05:30
parent d045dc6462
commit 5e82944199
No known key found for this signature in database
GPG Key ID: 5CABA3D642DDC497

View File

@ -1,4 +1,5 @@
import { defineLoader } from "vitepress"; import { defineLoader } from "vitepress";
import { writeFile, readFile } from "fs/promises";
interface Data { interface Data {
title?: string; title?: string;
@ -36,8 +37,10 @@ export default defineLoader({
guides.add({ title, url }); guides.add({ title, url });
} }
} }
return Object.fromEntries( const obj = Object.fromEntries(
[...guides.entries()].map((entry, index) => [index.toString(), entry]), [...guides.entries()].map((entry, index) => [index.toString(), entry]),
); );
await writeFile("./guides.json",JSON.stringify(obj, null, 4), "")
return await readFile("./guides.json", { encoding: "utf-8"})
}, },
}); });