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/clarify importing modules in SSR pages #178

Merged
merged 3 commits into from
Feb 10, 2025
Merged
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
7 changes: 5 additions & 2 deletions src/pages/docs/pages/server-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The above would serve content in a browser at the path _/users/_.

In your page file, Greenwood supports the following functions that you can `export` for providing server rendered content and [frontmatter](/docs/resources/markdown/) to produce the `<body><body>` content for your page.

- **default** (recommended): Use the custom elements API to render out your page content, aka **Web (Server) Components**. _This will take precedence over `getBody`_ and will also automatically track your custom element dependencies (in place of having to define frontmatter imports in `getFrontmatter`).
- **default** (recommended): Use the custom elements API to render out your page content, aka **Web (Server) Components**. _This will take precedence over `getBody`_ and will also automatically track your custom element dependencies (in place of having to define frontmatter imports in `getFrontmatter`). However, any custom elements tracked by this automatic dependency management _must_ be able to render on the server. Any elements that require the browser should be imported using the imports field in `getFrontmatter`.
lschierer marked this conversation as resolved.
Show resolved Hide resolved
- **getBody**: Return a string of HTML for the contents of the page
- **getLayout**: Return a string of HTML to act as the [page's layout](/docs/pages/layouts/#pages)
- **getFrontmatter**: Provide an object of [frontmatter](/docs/resources/markdown/#frontmatter) properties. Useful in conjunction with [content as data](/docs/content-as-data/), or otherwise setting static configuration / metadata through SSR.
Expand Down Expand Up @@ -209,7 +209,10 @@ Any Greenwood supported frontmatter can be returned here. _This is only run once
collection: "header",
order: 1,
title: `The ${route} page`,
imports: ["/components/user.js"],
imports: [
lschierer marked this conversation as resolved.
Show resolved Hide resolved
"/components/user.js",
"/components/otherItem.js type=module"
],
data: {
/* ... */
},
Expand Down