Skip to content

Commit

Permalink
docs/issue 149 clarify renderer plugin prerendering usage and options (
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Jan 27, 2025
1 parent adc343e commit cb9b39b
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit cb9b39b

Please sign in to comment.