You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/docs/pages/layouts.md
+41-30Lines changed: 41 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,15 +31,17 @@ src/
31
31
32
32
> **Note:** You can use either relative (_../_) or absolute (_/_) paths in your layouts since using _../_ will allow for IDE autocomplete on your filesystem, but is marginally slower than using _/_.
33
33
34
-
## Pages
34
+
## Page Layout
35
35
36
-
Pages in your project will generally want a layout so you can control the output of the HTML and include all your own custom components and styles to wrap the content. By default all pages will default to looking for a _page.html_ in the _layouts/_ directory. A placeholder of `<content-outlet></content-outlet>` can be used to position where the processed content from the incoming page will go.
36
+
Pages in your project will generally want a layout so you can control the output of the HTML and include all your own custom components and styles to wrap your content; think of a shared layout for all blog posts, which might be distinct from your home or docs pages. By default all pages will default to looking for a _page.html_ in the _layouts/_ directory. A placeholder of `<content-outlet></content-outlet>` can be used to position where the content from the incoming page will go.
37
+
38
+
> Dynamic layouts are [also supported](/docs/pages/server-rendering/#layouts).
@@ -81,15 +83,15 @@ You can create more layouts and use them for pages with the following steps:
81
83
82
84
<!-- prettier-ignore-end -->
83
85
84
-
## App
86
+
## App Layout
85
87
86
-
To customize the outer most wrapping HTML of your layouts, create an _app.html_ file. Like a page layout, this will just be another HTML document and a `<page-outlet></page-outlet>` placeholder that can be used to position where the content from the processed page layout will appear.
88
+
To customize the outer most wrapping HTML of _all_your pages, create an _app.html_ file. This is most useful for global page elements like headers, navigation, and footers. Like a page layout, this will just be another HTML document (or JS / TS file) with a `<page-outlet></page-outlet>` placeholder that can be used to position where the content from the processed page layout will appear.
@@ -114,34 +116,43 @@ As with Page layouts, App layouts are just HTML:
114
116
115
117
<!-- prettier-ignore-end -->
116
118
117
-
> When an app layout is present, Greenwood will merge the `<head>` and `<body>` tags for both app and page layouts into one HTML document structure for you.
119
+
> In general, you will want to start with an app layout, then create page specific layouts as needed for more specific custom layout needs.
118
120
119
121
## Server Rendering
120
122
121
123
Server rendered layouts can also be authored using Web Components:
> ⚠ This layout component will _only run once at build time_. Dynamic "runtime" layouts are [planned](https://github.com/ProjectEvergreen/greenwood/issues/1248).
Copy file name to clipboardExpand all lines: src/pages/docs/pages/routing.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,8 @@ src/
84
84
index.html
85
85
```
86
86
87
+
> [SPA based projects](/docs/pages/routing/#spa) do **not** support layouts or (active) frontmatter.
88
+
87
89
## Not Found
88
90
89
91
As is a [common convention with most hosting providers](https://docs.netlify.com/routing/redirects/redirect-options/#custom-404-page-handling) and web servers, you can create a `404` page in your _pages/_ directory which will be used as the default **Not Found** page for your site.
- WSCs run only on the server, thus you have full access to any APIs of the runtime, with the ability to perform one time `async` operations for [data loading](/docs/pages/server-rendering/#request-data) in `connectedCallback`.
107
107
- Keep in mind that for these "page" components, you will likely want to _avoid_ rendering into a shadow root, as then your content and styles will be encapsulated.
108
108
109
+
> You can also author [dynamic layouts](/docs/pages/layouts/#server-rendering) in this way as well!
110
+
109
111
### Body
110
112
111
113
To return just the body of the page, you can use the `getBody` API. You will get access to the [compilation](/docs/reference/appendix/#compilation), page specific data, and the incoming request.
@@ -114,7 +116,7 @@ In this example, we return a list of users from an API as HTML:
0 commit comments