remove guides page code

This commit is contained in:
taskylizard 2023-11-19 18:41:08 +00:00
parent 85b162616c
commit 5cfa04315e
2 changed files with 0 additions and 59 deletions

View File

@ -1,46 +0,0 @@
import { writeFile, readFile } from "node:fs/promises";
import { defineLoader } from "vitepress";
interface Data {
title?: string;
content?: string;
url?: string;
}
declare const data: Data;
export { data };
const page = "https://rentry.co/fmhy-guides/raw";
const regex = /\* \[([^\]]+)]\(([^)]+)\)/g;
const rentryRe = /(?<=rentry\.(co|org)).*/;
const guides = new Set<Data>();
const f = async (url: string) => {
const contents = await (await fetch(url))
.text()
.catch((error: Error) => console.error(`Failed at ${url}`, error));
return contents;
};
export default defineLoader({
async load(): Promise<Data> {
const contents = await f(page);
let match: any[] | null;
while ((match = regex.exec(contents)) !== null) {
const title = match[1];
const url = match[2];
// Fetch rentry guides
if (rentryRe.test(url)) {
const content = await f(`${url}/raw`);
guides.add({ title, content });
} else {
// Everything else can be here
guides.add({ title, url });
}
}
const obj = Object.fromEntries(
[...guides.entries()].map((entry, index) => [index.toString(), entry]),
);
await writeFile("./guides.json", JSON.stringify(obj, null, 4), "utf-8");
return JSON.parse(await readFile("./guides.json", { encoding: "utf-8" })) as Data;
},
});

View File

@ -1,13 +0,0 @@
---
title: Guides
---
<!-- <script setup> -->
<!-- import { data } from "./.vitepress/loaders/guides.data"; -->
<!-- </script> -->
<!---->
<!-- <template> -->
<!-- <h2>Guides</h2> -->
<!-- <br /> -->
<!-- <ul> -->
<!-- </ul> -->
<!-- </template> -->