Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,19 @@ This is just a file with access to global vars: ${testVar}`,
export default templateIterator
```

### Choosing a template return type

Use the simplest return type that fits your needs:

| Return type | Multiple outputs | Custom filename | Use when |
|---|---|---|---|
| String | No | No (derived from template filename) | Single file, filename from template name |
Comment thread
bcomnes marked this conversation as resolved.
Outdated
| Object | No | Yes | Single file with a custom output path |
| Array | Yes | Yes | Fixed set of output files known at build time |
| AsyncIterator | Yes | Yes | Any async work, or a dynamic number of outputs |

Start with a string return and only switch to a more complex type when you need what it provides. An async generator is the right choice when you need to do async work (such as calling `renderInnerPage` on multiple pages) and produce more than one output file.
Comment thread
bcomnes marked this conversation as resolved.
Outdated

### RSS Feed Template Example

Templates receive the standard variables available to pages, so its possible to perform page introspection and generate RSS feeds of website content.
Expand Down
Loading