aboutsummaryrefslogtreecommitdiff
path: root/demos/css-stress-test/bun-framework-next/page-loader.ts
blob: fdc6f5f281b526402af0621a96f6c37814a8c314 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import NextPageLoader from "next/dist/client/page-loader";

export default class PageLoader extends NextPageLoader {
  public routeLoader: RouteLoader;

  getPageList() {

  }


  loadPage(route: string): Promise<GoodPageCache> {
    return this.routeLoader.loadRoute(route).then((res) => {
      if ("component" in res) {
        return {
          page: res.component,
          mod: res.exports,
          styleSheets: res.styles.map((o) => ({
            href: o.href,
            text: o.content,
          })),
        };
      }
      throw res.error;
    });
  }

  prefetch(route: string): Promise<void> {
    return this.routeLoader.prefetch(route);
  }
}