Skip to content

Commit 6a1af2e

Browse files
authored
Merge pull request #56 from janniks/fix-content
Fix missing/pending blocks
2 parents 8b93b03 + bee30a7 commit 6a1af2e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/routes/page.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ export async function pageRoute(req: HandlerRequest) {
1616
let allBlockKeys;
1717

1818
while (true) {
19+
allBlockKeys = Object.keys(allBlocks);
1920

20-
allBlockKeys = allBlocks[pageId!].value.content
21+
const pendingBlocks = allBlockKeys.flatMap((blockId) => {
22+
const block = allBlocks[blockId];
23+
const content = block.value && block.value.content;
24+
25+
if (!content || (block.value.type === "page" && blockId !== pageId!)) {
26+
// skips pages other than the requested page
27+
return [];
28+
}
2129

22-
const pendingBlocks = allBlockKeys!.filter((blockId) => {
23-
return !allBlocks.hasOwnProperty(blockId)
30+
return content.filter((id: string) => !allBlocks[id]);
2431
});
2532

2633
if (!pendingBlocks.length) {

0 commit comments

Comments
 (0)