Skip to content

Formally document renderInnerPage() API and rendered content architecture #229

@bcomnes

Description

@bcomnes

This issue was originally identified in voxpelli/voxpelli.github.com#32

Problem

The renderInnerPage() method on PageData objects is the primary mechanism for accessing rendered HTML content from other pages — essential for RSS/Atom feeds, search indexes, and archive previews. The method is demonstrated in the README's "RSS Feed Template Example" but lacks formal dedicated documentation explaining its behavior, parameters, return value, and limitations.

This creates a discoverability gap: users who read the template documentation linearly may encounter renderInnerPage() in the RSS example, but there is no reference section explaining:

  • What the method does (renders inner page content without layout wrapper)
  • That renderFullPage() also exists (renders with layout applied)
  • That both methods require passing the full pages array
  • Performance considerations (parallel rendering, caching)
  • When these methods are available in the build pipeline

What's missing

1. Formal API reference for renderInnerPage() and renderFullPage()

// Available on PageData objects in templates and global.data.js
page.renderInnerPage({ pages }): Promise<string>   // Content without layout
page.renderFullPage({ pages }): Promise<any>        // Content with layout applied

2. Architecture explanation: when rendered content is available

The build pipeline has a clear ordering:

Build stage renderInnerPage() available? Why
global.data.js Yes Runs after page initialization
Page functions (page.js) No Pages receive vars, not other pages' rendered output
Templates (.template.js) Yes Run after page initialization and global data
Layouts No Receive already-rendered children for their own page

3. Performance guidance

For feeds and other outputs that render multiple pages:

  • Use Promise.all() for parallel rendering
  • Cache results in a Map when the same page appears in multiple outputs
// Build page index for O(1) lookup
const pagesByPath = new Map(pages.map(p => [p.pageInfo.path, p]));

// Pre-render all unique feed posts in parallel, with cache
const renderCache = new Map();
await Promise.all(allFeedPosts.map(async (post) => {
  const page = pagesByPath.get(post.path);
  const html = page ? await page.renderInnerPage({ pages }) : '';
  renderCache.set(post.path, html);
}));

Proposed solution

Add a "Accessing rendered page content" reference section near the Templates documentation:

### Accessing rendered page content

Templates and `global.data.js` can render any page's inner content using `renderInnerPage()`:

    const html = await page.renderInnerPage({ pages });

- `renderInnerPage({ pages })` returns the page content rendered by its builder
  (e.g., markdown-to-HTML), **without** the layout wrapper.
- `renderFullPage({ pages })` returns the complete page with layout applied.
- Both methods are async and require passing the full `pages` array.
- For performance, render in parallel with `Promise.all()` and cache results
  when multiple outputs need the same rendered content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationdxenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions