From a817c56b66d880a0368e9477af6b9a40ba779c86 Mon Sep 17 00:00:00 2001 From: Ajani Bilby <11359344+AjaniBilby@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:12:45 +1000 Subject: [PATCH] +search function --- builder/index.ts | 6 +- builder/page.ts | 34 +++++++++-- builder/search.ts | 10 ++++ builder/toolbar.ts | 2 +- client/index.ts | 14 +++-- client/search.ts | 82 ++++++++++++++++++++++++++ package-lock.json | 56 ++++++++++++++---- package.json | 4 ++ public/main.css | 140 ++++++++++++++++++++++++++++++++++++++++++--- 9 files changed, 316 insertions(+), 32 deletions(-) create mode 100644 builder/search.ts create mode 100644 client/search.ts diff --git a/builder/index.ts b/builder/index.ts index 797d719..5500dfb 100644 --- a/builder/index.ts +++ b/builder/index.ts @@ -1,6 +1,7 @@ import { CreateFolderPage, CreatePage } from "./page"; -import { readdir, stat, mkdir } from "fs/promises"; +import { readdir, stat, mkdir, writeFile } from "fs/promises"; import { CreateToolbar } from "./toolbar"; +import * as Search from "./search"; console.info("Building Docs..."); @@ -30,6 +31,9 @@ async function BuildDir(path: string) { await CreateFolderPage(toolbar, path); await Promise.all(folders.map(BuildDir)); + + + writeFile("./public/search.json", Search.Jsonify()); } diff --git a/builder/page.ts b/builder/page.ts index f035037..5e44bc9 100644 --- a/builder/page.ts +++ b/builder/page.ts @@ -1,27 +1,50 @@ import { readFile, writeFile } from "fs/promises"; import { Path2Name, Reroute } from "./helper"; +import { AddIndex } from "./search"; + + +const search = `