From f12a49f94f6a70ab93e2535a4b8715f5a22e4cab Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 18 Apr 2026 11:31:57 -0700 Subject: [PATCH 1/4] document renderInnerPage and renderFullPage API --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 008f8fb..c4fc52e 100644 --- a/README.md +++ b/README.md @@ -951,6 +951,27 @@ const feedsTemplate: TemplateAsyncIterator = async function * ({ export default feedsTemplate ``` +### Accessing rendered page content + +Any `PageData` instance exposes two methods for accessing rendered output: + +- `await page.renderInnerPage({ pages })` returns the page content as rendered by its builder (markdown converted to HTML, for example) without a layout wrapper applied. +- `await page.renderFullPage({ pages })` returns the complete page output with its layout applied. + +Both methods are async and require the full `pages` array. They are available inside templates and in `global.data.js`. They are not available inside page functions or layouts. + +For templates that render many pages, pre-render in parallel and cache results to avoid doing the same work twice when producing several output files from one template: + +```js +const renderCache = new Map() +await Promise.all(allPosts.map(async (page) => { + renderCache.set(page.pageInfo.path, await page.renderInnerPage({ pages })) +})) + +// later, when building output: +const html = renderCache.get(post.path) ?? '' +``` + ## Global Assets There are a few important (and optional) global assets that live anywhere in the `src` directory. If duplicate named files that match the global asset file name pattern are found, a build error will occur until the duplicate file error is resolved. From 49b3ef02484cd0994bcb130bf550510e93c88bcc Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 18 Apr 2026 12:02:34 -0700 Subject: [PATCH 2/4] Fix renderInnerPage availability note, cache key inconsistency, add pMap concurrency - Availability: renderInnerPage/renderFullPage are also callable from page functions and layouts, not just templates and global.data.js - Cache key: use page.pageInfo.path consistently (the read side previously used the undefined 'post.path') - Concurrency: switch the pre-render example from Promise.all to pMap with concurrency:4 to avoid unbounded parallelism on large sites --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c4fc52e..5a439d8 100644 --- a/README.md +++ b/README.md @@ -958,18 +958,20 @@ Any `PageData` instance exposes two methods for accessing rendered output: - `await page.renderInnerPage({ pages })` returns the page content as rendered by its builder (markdown converted to HTML, for example) without a layout wrapper applied. - `await page.renderFullPage({ pages })` returns the complete page output with its layout applied. -Both methods are async and require the full `pages` array. They are available inside templates and in `global.data.js`. They are not available inside page functions or layouts. +Both methods are async and require the full `pages` array. They are available inside templates, in `global.data.js`, inside page functions, and inside layouts. For templates that render many pages, pre-render in parallel and cache results to avoid doing the same work twice when producing several output files from one template: ```js +import pMap from 'p-map' + const renderCache = new Map() -await Promise.all(allPosts.map(async (page) => { +await pMap(allPosts, async (page) => { renderCache.set(page.pageInfo.path, await page.renderInnerPage({ pages })) -})) +}, { concurrency: 4 }) // later, when building output: -const html = renderCache.get(post.path) ?? '' +const html = renderCache.get(page.pageInfo.path) ?? '' ``` ## Global Assets From b0495615e8d43d2003b1d7cb263164a0da363225 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 18 Apr 2026 12:53:22 -0700 Subject: [PATCH 3/4] Clarify renderInnerPage return type description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a439d8..04824e5 100644 --- a/README.md +++ b/README.md @@ -955,7 +955,7 @@ export default feedsTemplate Any `PageData` instance exposes two methods for accessing rendered output: -- `await page.renderInnerPage({ pages })` returns the page content as rendered by its builder (markdown converted to HTML, for example) without a layout wrapper applied. +- `await page.renderInnerPage({ pages })` returns the page's inner render output as produced by its builder, without a layout wrapper applied. This is often an HTML string (for example, markdown rendered to HTML), but the type depends on the page builder. - `await page.renderFullPage({ pages })` returns the complete page output with its layout applied. Both methods are async and require the full `pages` array. They are available inside templates, in `global.data.js`, inside page functions, and inside layouts. From 1de39fecf764790fbb3cb57a08b23b01759fdeea Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 18 Apr 2026 19:50:06 -0700 Subject: [PATCH 4/4] Add caveat that render methods require successful PageData initialization Co-Authored-By: Claude Sonnet 4.6 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 04824e5..604470e 100644 --- a/README.md +++ b/README.md @@ -960,6 +960,8 @@ Any `PageData` instance exposes two methods for accessing rendered output: Both methods are async and require the full `pages` array. They are available inside templates, in `global.data.js`, inside page functions, and inside layouts. +These methods also require that the `PageData` instance was successfully initialized first. When iterating the full `pages` array -- especially in `global.data.js` -- some entries may represent pages that failed initialization before the build aborts, and calling `renderInnerPage()` or `renderFullPage()` on those pages will throw. + For templates that render many pages, pre-render in parallel and cache results to avoid doing the same work twice when producing several output files from one template: ```js