lazy.ts
1.4 kB · typescript · 33 lines
1import { got, lazy, put } from "../kinds.js";2import { wear } from "./sheets.ts";34const LOAD: Record<string, () => Promise<unknown>> = {5 home: () => import("../pages/Home.jsx").then((one) => one.Home),6 shop: () => import("../pages/Shop.jsx").then((one) => one.Shop),7 designs: () => import("../pages/Designs.jsx").then((one) => one.Designs),8 product: () => import("../pages/Product.jsx").then((one) => one.Product),9 post: () => import("../pages/Post.jsx").then((one) => one.Post),10 feed: () => import("../pages/Feed.jsx").then((one) => one.Feed),11 cart: () => import("../pages/Cart.jsx").then((one) => one.Cart),12 code: () => import("../pages/Code.jsx").then((one) => one.Code),13 automator: () => import("../pages/Automator.jsx").then((one) => one.Automator),14 stats: () => import("../pages/Stats.jsx").then((one) => one.Stats),15 pages: () => import("../pages/Pages.jsx").then((one) => one.Pages),16 gifts: () => import("../pages/GiftCard.jsx").then((one) => one.GiftCards),17 gift: () => import("../pages/GiftCard.jsx").then((one) => one.GiftCard),18 page: () => import("../pages/Doc.jsx").then((one) => one.Doc),19 blog: () => import("../pages/Blog.jsx").then((one) => one.Blog),20};2122async function code(kind: string) {23 if (got(kind)) return;24 const one = LOAD[kind];25 if (!one) return;26 put(kind, await one());27}2829export async function load(kind: string) {30 await Promise.all([code(kind), wear(kind)]);31}3233lazy(load);