Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/issue 149 clarify renderer plugin prerendering usage and options #152

Merged
Changes from all commits
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
12 changes: 7 additions & 5 deletions src/pages/docs/reference/plugins-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ If you need to copy files out of _node_modules_, you can use some of Greenwood's

## Renderer

Renderer plugins allow users to customize how Greenwood server renders (and prerenders) your project. By default, Greenwood supports using [**WCC** or (template) strings](/docs/pages/server-rendering/) to return static HTML for the content and template of your server side routes. With this plugin for example, you can use [Lit's SSR](https://github.com/lit/lit/tree/main/packages/labs/ssr) to render your Lit Web Components on the server side instead. (but don't do that one specifically, we already have [a plugin](/docs/plugins/lit-ssr/) for Lit 😊)
Renderer plugins are the way to customize how Greenwood server renders (and prerenders) your project. By default, Greenwood supports using [**WCC** or (template) strings](/docs/pages/server-rendering/) to return static HTML for the content and layouts of your server side routes. For example, you can use [Lit's SSR capabilities](https://github.com/lit/lit/tree/main/packages/labs/ssr) to render your Lit Web Components on the server side instead. (but don't do that one specifically, we already have [a plugin](/docs/plugins/lit-ssr/) for Lit 😊)

> Note: Only **one** renderer plugin can be used at a time.

### API

Expand All @@ -342,14 +344,13 @@ This plugin expects to be given a path to a module that exports a function to ex
<app-ctc-block variant="snippet" heading="my-renderer-plugin.js">

```js
const greenwoodPluginMyCustomRenderer = (options = {}) => {
const greenwoodPluginMyCustomRenderer = () => {
return {
type: "renderer",
name: "plugin-renderer-custom",
provider: () => {
return {
executeModuleUrl: new URL("./execute-route-module.js", import.meta.url),
prerender: options.prerender,
};
},
};
Expand All @@ -362,13 +363,14 @@ This plugin expects to be given a path to a module that exports a function to ex

<!-- prettier-ignore-end -->

<!-- eslint-enable no-unused-vars -->

#### Options

This plugin type supports the following options:

- **executeModuleUrl** (recommended) - `URL` to the location of a file with the SSR rendering implementation
- **customUrl** - `URL` to a file that has a `default export` of a function for handling the _prerendering_ lifecyle of a Greenwood build, and running the provided callback function
- **prerender** (optional) - Flag can be used to indicate if this custom renderer should be used to statically [prerender](/docs/reference/configuration/#prerender) pages too.
- **customUrl** - `URL` to a file that has a `default export` of a function for handling the _prerendering_ lifecycle of a Greenwood build, and running the provided callback function

### Examples

Expand Down
Loading