From f0c4e538afc80d7d516ea3411717dedcf3e99ed9 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Wed, 21 Feb 2024 02:20:11 -0600 Subject: [PATCH 1/3] docs: Rewrite prerendering instructions --- README.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c30bfbd..2025c18 100644 --- a/README.md +++ b/README.md @@ -75,19 +75,31 @@ preact({ | Option | Type | Default | Description | |---|---|---|---| | `enabled` | `boolean` | `false` | Enables prerendering | -| `prerenderScript` | `string` | `undefined` | Absolute path to script containing exported `prerender()` function. If not provided, will try to find the prerender script in the scripts listed in your HTML entrypoint | | `renderTarget` | `string` | `"body"` | Query selector for where to insert prerender result in your HTML template | -| `additionalPrerenderRoutes` | `string` | `undefined` | Prerendering will automatically discover links to prerender, but if there are unliked pages that you want to prererender (such as a `/404` page), use this option to specify them | +| `prerenderScript` | `string` | `undefined` | Absolute path to script containing exported `prerender()` function. If not provided, will try to find the prerender script in the scripts listed in your HTML entrypoint | +| `additionalPrerenderRoutes` | `string[]` | `undefined` | Prerendering will crawl your site automatically, but you'd like to prerender some pages that may not be found (such as a `/404` page), use this option to specify them | + +To prerender your app, you'll need to do three things: +1. Enable prerendering in the plugin options +2. Specify your render target, if you want the HTML to be inserted anywhere other than the `document.body`. This location likely should match `render()`, i.e., `render(, document.querySelector('#app'))` -> `'#app'` +4. Create and export a `prerender` function from a script. You could add this to your app entrypoint or create a completely separate file for it, either will work. See below for a usage example +5. Specify where your `prerender` function is by either a) adding a `prerender` attribute to the script tag that contains it in your entry HTML (`