diff --git a/apps/web/src/pages/browse/[title]/[chapter].astro b/apps/web/src/pages/browse/[title]/[chapter].astro index 12ecc6a..40b2616 100644 --- a/apps/web/src/pages/browse/[title]/[chapter].astro +++ b/apps/web/src/pages/browse/[title]/[chapter].astro @@ -51,20 +51,17 @@ const sectionMeta = sortedSections.map((entry) => { return { entry, isInactive, statusLabel }; }); -// Only render full content at build time for small chapters (≤50 sections) -// Large chapters render on-demand via the toggle +// Statically compile all section bodies into the chapter rollup at build time +const renderedSections = await Promise.all( + sectionMeta.map(async ({ entry, isInactive, statusLabel }) => { + const { Content } = await render(entry); + return { entry, Content, isInactive, statusLabel }; + }) +); + const INLINE_THRESHOLD = 50; const isSmallChapter = sortedSections.length <= INLINE_THRESHOLD; -const renderedSections = isSmallChapter - ? await Promise.all( - sectionMeta.map(async ({ entry, isInactive, statusLabel }) => { - const { Content } = await render(entry); - return { entry, Content, isInactive, statusLabel }; - }) - ) - : []; - const base = import.meta.env.BASE_URL; const activeCount = sectionMeta.filter(s => !s.isInactive).length; --- @@ -135,42 +132,36 @@ const activeCount = sectionMeta.filter(s => !s.isInactive).length; - +
- {isSmallChapter ? ( - renderedSections.map(({ entry, Content, isInactive, statusLabel }) => ( -
- -
- + {renderedSections.map(({ entry, Content, isInactive, statusLabel }) => ( + - )) - ) : ( - - )} +
+
+ +
+
+ ))}
@@ -180,126 +171,79 @@ const activeCount = sectionMeta.filter(s => !s.isInactive).length; - + {!isSmallChapter && ( )} - - {isSmallChapter && ( - - )} + }); + })(); +