www: new fenced code block design (#1629)
This commit is contained in:
@@ -7,16 +7,16 @@ An route layout is defined in a `_layout.tsx` file in any sub directory (at any
|
||||
level) under the `routes/` folder. It must contain a default export that is a
|
||||
regular Preact component. Only one such layout is allowed per sub directory.
|
||||
|
||||
```sh
|
||||
routes/
|
||||
_app.tsx
|
||||
_layout.tsx # will be applied to all routes
|
||||
/sub
|
||||
index.tsx
|
||||
page.tsx
|
||||
/other
|
||||
_layout.tsx # will be applied on top of `routes/_layout.tsx`
|
||||
page.tsx
|
||||
```txt Project structure
|
||||
└── routes
|
||||
├── sub
|
||||
│ ├── page.tsx
|
||||
│ └── index.tss
|
||||
├── other
|
||||
│ ├── _layout.tsx # will be applied on top of `routes/_layout.tsx`
|
||||
│ └── page.tsx
|
||||
├── _layout.tsx # will be applied to all routes
|
||||
└── _app.tsx
|
||||
```
|
||||
|
||||
The component to be wrapped is received via props, in addition to a few other
|
||||
@@ -24,9 +24,7 @@ things. This allows for the introduction of a global container functioning as a
|
||||
template which can be conditioned based on state and params. Note that any state
|
||||
set by middleware is available via `props.state`.
|
||||
|
||||
```tsx
|
||||
// routes/sub/_layout.tsx
|
||||
|
||||
```tsx routes/sub/_layout.tsx
|
||||
import { LayoutProps } from "$fresh/server.ts";
|
||||
|
||||
export default function Layout({ Component, state }: LayoutProps) {
|
||||
@@ -45,20 +43,19 @@ Sometimes you want to opt out of the layout inheritance mechanism for a
|
||||
particular route. This can be done via route configuration. Picture a directory
|
||||
structure like this:
|
||||
|
||||
```sh
|
||||
routes/
|
||||
_layout.tsx
|
||||
/sub
|
||||
_layout.tsx
|
||||
index.tsx
|
||||
special.tsx # should not inherit layouts
|
||||
```txt Project structure
|
||||
└── routes
|
||||
├── sub
|
||||
│ ├── _layout_.tsx
|
||||
│ ├── special.tsx # should not inherit layouts
|
||||
│ └── index.tss
|
||||
└── _layout.tsx
|
||||
```
|
||||
|
||||
To make `routes/sub/special.tsx` opt out of rendering layouts we can set
|
||||
`rootLayout: true`.
|
||||
|
||||
```tsx
|
||||
// routes/sub/special.tsx
|
||||
```tsx routes/sub/special.tsx
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
|
||||
Reference in New Issue
Block a user