Skip to content

Commit

Permalink
Don’t reload to a supplemental file.
Browse files Browse the repository at this point in the history
Fixes #6026
  • Loading branch information
dragonstyle committed Jun 26, 2023
1 parent b56f5d2 commit e142436
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/project/serve/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,25 @@ export function watchProject(
resourceFiles,
project!,
);

// Filter out supplmental files (e.g. files that were injected as supplements)
// to the render. Instead, we should return the first non-supplemental file.
// Example of supplemental file is a user rendering a post that appears in a listing
// - the listing will be added as a supplement since changes in the post may change the
// listing itself
const nonSupplementalFiles = result.files.filter(
(renderResultFile) => {
return !renderResultFile.supplemental;
},
);

return {
config: false,
output: true,
reloadTarget:
(result.files.length && !isPdfContent(result.files[0].file))
? join(outputDir, result.files[0].file)
: undefined,
reloadTarget: (nonSupplementalFiles.length &&
!isPdfContent(nonSupplementalFiles[0].file))
? join(outputDir, nonSupplementalFiles[0].file)
: undefined,
};
}
} finally {
Expand Down

0 comments on commit e142436

Please sign in to comment.