Skip to content

Commit

Permalink
feat: delay loading pages.json
Browse files Browse the repository at this point in the history
  • Loading branch information
KeJunMao committed Mar 7, 2023
1 parent 9f9648a commit 6e8b9c9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ export class Context {
layouts: Layout[];
constructor(options: ResolvedOptions) {
this.options = options;
this.pages = loadPagesJson("src/pages.json", options.cwd);
this.pages = {
pages: [],
};
this.layouts = scanLayouts(options.layoutDir, options.cwd);
}

transform(code: string, path: string) {
if (!this.pages.pages?.length) {
this.pages = loadPagesJson("src/pages.json", this.options.cwd);
}
const page = getTarget(path, this.pages.pages, this.options.layout);
if (!page) return;
if (!this.layouts.length) return;
Expand Down

0 comments on commit 6e8b9c9

Please sign in to comment.