Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions docs/latest/advanced/app-wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you're using [file-based routing](/docs/concepts/file-routing), create a
## Basic example

```tsx routes/_app.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export default define.page(({ Component, url }) => {
return (
Expand Down Expand Up @@ -84,7 +84,7 @@ The app wrapper receives the same props as page components - `url`, `state`,
`params`, and more. This is useful for conditional logic:

```tsx routes/_app.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export default define.page(({ Component, url, state }) => {
return (
Expand Down Expand Up @@ -112,7 +112,7 @@ structure. Use `skipAppWrapper` in the route config:

```tsx routes/embed.tsx
import { type RouteConfig } from "fresh";
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export const config: RouteConfig = {
skipAppWrapper: true,
Expand Down
4 changes: 2 additions & 2 deletions docs/latest/advanced/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This example demonstrates how to handle `application/x-www-form-urlencoded`
`<form>` submissions:

```tsx routes/subscribe.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export const handlers = define.handlers({
async GET(ctx) {
Expand Down Expand Up @@ -65,7 +65,7 @@ that this time, we have to explicitly declare the form's encoding to be
`multipart/form-data`.

```tsx routes/subscribe.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export const handler = define.handlers({
async GET(ctx) {
Expand Down
6 changes: 3 additions & 3 deletions docs/latest/advanced/partials.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The quickest way to get started is to enable partials for every page in
`routes/_app.tsx` by making the following changes.

```diff routes/_app.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";
+ import { Partial } from "fresh/runtime";

export default define.page(function App({ Component }) {
Expand Down Expand Up @@ -81,7 +81,7 @@ documentation (marked green here).
The code for such a page (excluding styling) might look like this:

```tsx routes/docs/[id].tsx
import { define } from "../../utils.ts";
import { define } from "@/utils.ts";

export default define.page(async (ctx) => {
const content = await loadContent(ctx.params.id);
Expand All @@ -104,7 +104,7 @@ An optimal route that only renders the content instead of the outer layout with
the sidebar might look like this respectively.

```tsx routes/partials/docs/[id].tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";
import { Partial } from "fresh/runtime";

// We only want to render the content, so disable
Expand Down
8 changes: 4 additions & 4 deletions docs/latest/concepts/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ and `url`. Any state set by [middleware](/docs/concepts/middleware) is available
via `props.state`.

```tsx routes/_layout.tsx
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export default define.layout(({ Component, state, url }) => {
return (
Expand All @@ -71,7 +71,7 @@ export default define.layout(({ Component, state, url }) => {
Layouts can be async to fetch data before rendering:

```tsx routes/blog/_layout.tsx
import { define } from "../../utils.ts";
import { define } from "@/utils.ts";

export default define.layout(async (ctx) => {
const categories = await db.categories.list();
Expand Down Expand Up @@ -104,7 +104,7 @@ config to skip all layouts inherited from parent directories:

```tsx routes/login.tsx
import { type RouteConfig } from "fresh";
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export const config: RouteConfig = {
skipInheritedLayouts: true,
Expand All @@ -129,7 +129,7 @@ useful when a section of your site needs a completely different shell:

```tsx routes/admin/_layout.tsx
import { type LayoutConfig } from "fresh";
import { define } from "../../utils.ts";
import { define } from "@/utils.ts";

export const config: LayoutConfig = {
skipInheritedLayouts: true,
Expand Down
6 changes: 3 additions & 3 deletions docs/latest/concepts/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ excellent way to make http-related logic reusable on the server.
Use the `define.middleware()` helper to get typings out of the box:

```ts middleware/my-middleware.ts
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

const middleware = define.middleware(async (ctx) => {
console.log("my middleware");
Expand All @@ -63,7 +63,7 @@ middleware in a `_middleware.ts` file inside the `routes/` folder or any of its
subfolders.

```ts routes/_middleware.ts
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export default define.middleware(async (ctx) => {
console.log("my middleware");
Expand All @@ -74,7 +74,7 @@ export default define.middleware(async (ctx) => {
You can also export an array of middlewares:

```ts routes/_middleware.ts
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

const middleware1 = define.middleware(async (ctx) => {
console.log("A");
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/examples/sharing-state-between-islands.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Then wire them together from a route, passing the same signal to both:
import { useSignal } from "@preact/signals";
import AddToCart from "../islands/AddToCart.tsx";
import Cart from "../islands/Cart.tsx";
import { define } from "../utils.ts";
import { define } from "@/utils.ts";

export default define.page(function CartPage() {
const cart = useSignal<string[]>([]);
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { define } from "@/utils.ts";
import { Button } from "@/components/Button.tsx";

// Without alias (relative paths)
import { define } from "../utils.ts";
import { define } from "@/utils.ts";
import { Button } from "../components/Button.tsx";
```

Expand Down
10 changes: 5 additions & 5 deletions docs/latest/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test assumes the `State` object in `utils.ts` has `text` property.
```ts tests/middleware.test.ts
import { expect } from "@std/expect";
import { App } from "fresh";
import { define, type State } from "../utils.ts";
import { define, type State } from "@/utils.ts";

const middleware = define.middleware((ctx) => {
ctx.state.text = "middleware text";
Expand Down Expand Up @@ -50,7 +50,7 @@ Both the [app wrapper](/docs/advanced/app-wrapper) component and
```tsx tests/appWrapper.test.tsx
import { expect } from "@std/expect";
import { App } from "fresh";
import { define, type State } from "../utils.ts";
import { define, type State } from "@/utils.ts";

const AppWrapper = define.layout(function AppWrapper({ Component }) {
return (
Expand Down Expand Up @@ -85,7 +85,7 @@ Same can be done for layouts.
```tsx tests/layout.test.tsx
import { expect } from "@std/expect";
import { App } from "fresh";
import { define, type State } from "../utils.ts";
import { define, type State } from "@/utils.ts";

const MyLayout = define.layout(function MyLayout({ Component }) {
return (
Expand Down Expand Up @@ -120,7 +120,7 @@ handler:
```ts tests/routes.test.ts
import { expect } from "@std/expect";
import { App } from "fresh";
import { type State } from "../utils.ts";
import { type State } from "@/utils.ts";

// Import actual route handlers
import { handler as apiHandler } from "../routes/api/[name].tsx";
Expand Down Expand Up @@ -152,7 +152,7 @@ to use JSX:
import { expect } from "@std/expect";
import { App } from "fresh";
import { useSignal } from "@preact/signals";
import { type State } from "../utils.ts";
import { type State } from "@/utils.ts";
import Counter from "../islands/Counter.tsx";

function CounterPage() {
Expand Down