-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demo: add site metadata generation (#3268)
- Loading branch information
1 parent
86c1d59
commit a8cd424
Showing
6 changed files
with
81 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
demo/site/src/recursivelyLoadBlockData.ts → ...site/src/util/recursivelyLoadBlockData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { BlockLoader, BlockLoaderDependencies, recursivelyLoadBlockData as cometRecursivelyLoadBlockData } from "@comet/cms-site"; | ||
|
||
import { loader as newsDetailLoader } from "./news/blocks/NewsDetailBlock.loader"; | ||
import { loader as newsListLoader } from "./news/blocks/NewsListBlock.loader"; | ||
import { loader as newsDetailLoader } from "@src/news/blocks/NewsDetailBlock.loader"; | ||
import { loader as newsListLoader } from "@src/news/blocks/NewsListBlock.loader"; | ||
|
||
declare module "@comet/cms-site" { | ||
export interface BlockLoaderDependencies { | ||
pageTreeNodeId?: string; | ||
} | ||
} | ||
|
||
export const blockLoaders: Record<string, BlockLoader> = { | ||
const blockLoaders: Record<string, BlockLoader> = { | ||
NewsDetail: newsDetailLoader, | ||
NewsList: newsListLoader, | ||
}; | ||
|
||
//small wrapper for @comet/cms-site recursivelyLoadBlockData that injects blockMeta from block-meta.json | ||
export async function recursivelyLoadBlockData(options: { blockType: string; blockData: unknown } & BlockLoaderDependencies) { | ||
const blocksMeta = await import("../block-meta.json"); //dynamic import to avoid this json in client bundle | ||
const blocksMeta = await import("../../block-meta.json"); //dynamic import to avoid this json in client bundle | ||
return cometRecursivelyLoadBlockData({ ...options, blocksMeta: blocksMeta.default, loaders: blockLoaders }); | ||
} |