www: cleanup miscellaneous doc items (#1419)
This commit is contained in:
@@ -9,16 +9,14 @@ wrapper is allowed per application.
|
||||
|
||||
The component to be wrapped is received via props, in addition to a few other
|
||||
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`.
|
||||
template which can be conditioned based on state and params.
|
||||
|
||||
```tsx
|
||||
// routes/_app.tsx
|
||||
|
||||
import { AppProps } from "$fresh/server.ts";
|
||||
|
||||
export default function App({ Component, state }: AppProps) {
|
||||
//do something with state here
|
||||
export default function App({ Component }: AppProps) {
|
||||
return (
|
||||
<div class="wrapper">
|
||||
<Component />
|
||||
|
||||
@@ -54,7 +54,7 @@ Islands support passing JSX elements via the `children` property. This allows
|
||||
you to pass static content rendered by the server to an island in the browser.
|
||||
|
||||
```jsx
|
||||
// file: /route/index.tsx
|
||||
// route/index.tsx
|
||||
import MyIsland from "../islands/my-island.tsx";
|
||||
|
||||
export default function Home() {
|
||||
@@ -78,7 +78,7 @@ like a normal Preact component, but still receive the serialized props if any
|
||||
were present.
|
||||
|
||||
```jsx
|
||||
// file: /route/index.tsx
|
||||
// route/index.tsx
|
||||
import MyIsland from "../islands/my-island.tsx";
|
||||
import OtherIsland from "../islands/other-island.tsx";
|
||||
|
||||
@@ -98,7 +98,7 @@ a way that's most optimal for your use app. We'll keep sending only the
|
||||
JavaScript that is needed for the islands to the browser.
|
||||
|
||||
```jsx
|
||||
// file: /route/index.tsx
|
||||
// route/index.tsx
|
||||
import MyIsland from "../islands/my-island.tsx";
|
||||
import OtherIsland from "../islands/other-island.tsx";
|
||||
|
||||
|
||||
+12
-12
@@ -10,10 +10,7 @@ use-cases for this are logging, authentication, and performance monitoring.
|
||||
|
||||
Each middleware gets passed a `next` function in the context argument that is
|
||||
used to trigger child handlers. The `ctx` also has a `state` property that can
|
||||
be used to pass arbitrary data to downstream (or upstream) handlers. This
|
||||
`state` is included in `PageProps` by default, which is available to both the
|
||||
special [\_app](/docs/concepts/app-wrapper.md) wrapper and normal
|
||||
[routes](/docs/concepts/routes.md).
|
||||
be used to pass arbitrary data to downstream (or upstream) handlers.
|
||||
|
||||
```ts
|
||||
// routes/_middleware.ts
|
||||
@@ -50,11 +47,15 @@ specific first).
|
||||
|
||||
For example, take a project with the following routes:
|
||||
|
||||
- `routes/_middleware.ts`
|
||||
- `routes/index.ts`
|
||||
- `routes/admin/_middleware.ts`
|
||||
- `routes/admin/index.ts`
|
||||
- `routes/admin/signin.ts`
|
||||
```
|
||||
└── routes
|
||||
├── _middleware.ts
|
||||
├── index.ts
|
||||
└── admin
|
||||
├── _middleware.ts
|
||||
└── index.ts
|
||||
└── signin.ts
|
||||
```
|
||||
|
||||
For a request to `/` the request will flow like this:
|
||||
|
||||
@@ -113,9 +114,8 @@ and `router.DestinationKind` is defined like this:
|
||||
export type DestinationKind = "internal" | "static" | "route" | "notFound";
|
||||
```
|
||||
|
||||
This is useful for if you want your middleware to only run when a request is
|
||||
headed for a `route`, as opposed to something like
|
||||
`http://localhost:8001/favicon.ico`.
|
||||
This is useful if you want your middleware to only run when a request is headed
|
||||
for a `route`, as opposed to something like `http://localhost:8001/favicon.ico`.
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
description: Plugins can add new functionality to Fresh without requiring significant complexity.
|
||||
---
|
||||
|
||||
> Plugins are only available in Fresh 1.1 and above.
|
||||
|
||||
Plugins can dynamically add new functionality to Fresh without exposing
|
||||
significant complexity to the user. Users can add plugins by importing and
|
||||
initializing them in their `main.ts` file:
|
||||
@@ -42,7 +40,7 @@ available (explained below).
|
||||
|
||||
A Fresh plugin is just a JavaScript object that conforms to the
|
||||
[Plugin](https://deno.land/x/fresh/server.ts?s=Plugin) interface. The only
|
||||
required property of a plugin is it's name. Names must only contain the
|
||||
required property of a plugin is its name. Names must only contain the
|
||||
characters `a`-`z`, and `_`.
|
||||
|
||||
```ts
|
||||
|
||||
@@ -18,8 +18,8 @@ The component is the template for a page. It is a JSX element that is rendered
|
||||
on the server. The page component gets passed props that can be used by it to
|
||||
determine exactly what should be rendered. By default components receives props
|
||||
consisting of: the request URL, the matching route (as a string), the matches
|
||||
from the URL pattern match, any state set by middleware, and any data passed to
|
||||
the handler's `render` function.
|
||||
from the URL pattern match, and any data passed to the handler's `render`
|
||||
function.
|
||||
|
||||
## Handler route
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export default function Page() {
|
||||
```
|
||||
|
||||
Fresh also does this automatically for `src` and `srcset` attributes in `<img>`
|
||||
and `<source>` HTML tags. These will automatically use "locked" paths if fresh
|
||||
and `<source>` HTML tags. These will automatically use "locked" paths if Fresh
|
||||
deems it safe to do so. You can always opt out of this behaviour per tag, by
|
||||
adding the `data-fresh-disable-lock` attribute.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user