@@ -31,7 +31,7 @@ Here is an example of an island component that counts down to a specific time.
|
||||
// islands/Countdown.tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h, useEffect, useMemo, useState } from "../client_deps.ts";
|
||||
import { h, useEffect, useMemo, useState } from "../deps.client.ts";
|
||||
|
||||
const timeFmt = new Intl.RelativeTimeFormat("en-US");
|
||||
|
||||
@@ -73,7 +73,7 @@ client with the correct props:
|
||||
// routes/countdown.tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h } from "../client_deps.ts";
|
||||
import { h } from "../deps.client.ts";
|
||||
import { Countdown } from "../islands/Countdown.tsx";
|
||||
|
||||
export default function Page() {
|
||||
|
||||
@@ -29,11 +29,11 @@ files, only two are strictly necessary for a fresh project:
|
||||
In addition to these two files, two other files are created that manage
|
||||
dependencies:
|
||||
|
||||
- **`client_deps.ts`**: This file contains dependencies that you need on the
|
||||
- **`deps.client.ts`**: This file contains dependencies that you need on the
|
||||
client, and possibly also on the server. It should be assumed that all of the
|
||||
dependencies referenced by this file will be shipped to the client. By
|
||||
default, it just re-exports the `fresh` runtime.
|
||||
- **`server_deps.ts`**: This file contains dependencies that are only used on
|
||||
- **`deps.server.ts`**: This file contains dependencies that are only used on
|
||||
the server. These are often things like database drivers, API clients, or
|
||||
other code that should only be executed on the server. This file should never
|
||||
be referenced by modules that might be shipped to the client. By default this
|
||||
|
||||
@@ -38,7 +38,7 @@ This is done with JSX.
|
||||
// routes/about.tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h } from "../client_deps.ts";
|
||||
import { h } from "../deps.client.ts";
|
||||
|
||||
export default function AboutPage() {
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,7 @@ then adds a custom header to the response before returning it:
|
||||
// routes/about.tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h, Handlers } from "../client_deps.ts";
|
||||
import { h, Handlers } from "../deps.client.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req, ctx) {
|
||||
@@ -58,7 +58,7 @@ response:
|
||||
```ts
|
||||
// routes/api/random-uuid.ts
|
||||
|
||||
import { Handlers } from "../client_deps.ts";
|
||||
import { Handlers } from "../deps.client.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req) {
|
||||
|
||||
@@ -28,7 +28,7 @@ as arguments in it's `props` object though.
|
||||
// routes/greet/[name].tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h, PageProps } from "../../client_deps.ts";
|
||||
import { h, PageProps } from "../../deps.client.ts";
|
||||
|
||||
export default function AboutPage(props: PageProps) {
|
||||
const { name } = props.params;
|
||||
|
||||
@@ -24,8 +24,8 @@ renders it in a page component.
|
||||
// routes/github/[username].tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h, PageProps } from "../../client_deps.ts";
|
||||
import { Handlers } from "../../server_deps.ts";
|
||||
import { h, PageProps } from "../../deps.client.ts";
|
||||
import { Handlers } from "../../deps.server.ts";
|
||||
|
||||
interface User {
|
||||
login: string;
|
||||
|
||||
@@ -33,8 +33,8 @@ server side:
|
||||
// routes/search.tsx
|
||||
|
||||
/** @jsx h */
|
||||
import { h, PageProps } from "../../client_deps.ts";
|
||||
import { Handlers } from "../../server_deps.ts";
|
||||
import { h, PageProps } from "../../deps.client.ts";
|
||||
import { Handlers } from "../../deps.server.ts";
|
||||
|
||||
const NAMES = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Frank"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user