Start renaming
This commit is contained in:
@@ -13,7 +13,7 @@ A handler fetches data and returns it with `page()`. The page component receives
|
||||
it in `props.data`:
|
||||
|
||||
```tsx routes/projects/[id].tsx
|
||||
import { HttpError, page } from "fresh";
|
||||
import { HttpError, page } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
interface Data {
|
||||
@@ -60,7 +60,7 @@ For simpler cases, you can fetch data directly in an async component without a
|
||||
separate handler:
|
||||
|
||||
```tsx routes/projects/[id].tsx
|
||||
import { HttpError } from "fresh";
|
||||
import { HttpError } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export default define.page(async (ctx) => {
|
||||
@@ -97,7 +97,7 @@ export default define.middleware(async (ctx) => {
|
||||
```
|
||||
|
||||
```tsx routes/dashboard.tsx
|
||||
import { page } from "fresh";
|
||||
import { page } from "sweet";
|
||||
import { define } from "@/utils.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
|
||||
@@ -11,7 +11,7 @@ in `vite.config.ts`). When you add a new file there, it will register a new
|
||||
route automatically.
|
||||
|
||||
```ts main.ts
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
|
||||
const app = new App({ basePath: "/foo" })
|
||||
.use(staticFiles())
|
||||
@@ -85,7 +85,7 @@ A custom [URL pattern][urlpattern] can be specified in the route configuration.
|
||||
This pattern will be used instead of the file path based pattern:
|
||||
|
||||
```ts routes/my-route.ts
|
||||
import { RouteConfig } from "fresh";
|
||||
import { RouteConfig } from "sweet";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
routeOverride: "/x/:module@:version/:path*",
|
||||
|
||||
@@ -29,7 +29,7 @@ An island can be used anywhere like a regular Preact component. Fresh will take
|
||||
care of making it interactive on the client.
|
||||
|
||||
```tsx main.tsx
|
||||
import { App, staticFiles } from "fresh";
|
||||
import { App, staticFiles } from "sweet";
|
||||
import MyIsland from "./islands/my-island.tsx";
|
||||
|
||||
const app = new App()
|
||||
@@ -77,7 +77,7 @@ A powerful feature of Fresh is that you can pass server-rendered JSX to an
|
||||
island via props.
|
||||
|
||||
```tsx routes/index.tsx
|
||||
import { staticFiles } from "fresh";
|
||||
import { staticFiles } from "sweet";
|
||||
import MyIsland from "../islands/my-island.tsx";
|
||||
|
||||
const app = new App()
|
||||
@@ -126,7 +126,7 @@ constant from `fresh/runtime` to guard browser-only code. It is `false` on the
|
||||
server and `true` in the browser:
|
||||
|
||||
```tsx islands/my-island.tsx
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function MyIsland() {
|
||||
// Return any prerenderable JSX here which makes sense for your island
|
||||
@@ -150,7 +150,7 @@ Use an island to register and render custom elements:
|
||||
|
||||
```tsx islands/MyElement.tsx
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function MyElement() {
|
||||
useEffect(() => {
|
||||
@@ -182,7 +182,7 @@ inside an island:
|
||||
|
||||
```tsx islands/ThirdPartyElement.tsx
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { IS_BROWSER } from "fresh/runtime";
|
||||
import { IS_BROWSER } from "sweet/runtime";
|
||||
|
||||
export function ShoelaceButton() {
|
||||
useEffect(() => {
|
||||
|
||||
@@ -103,7 +103,7 @@ full-screen dashboard, or a print view. Use `skipInheritedLayouts` in the route
|
||||
config to skip all layouts inherited from parent directories:
|
||||
|
||||
```tsx routes/login.tsx
|
||||
import { type RouteConfig } from "fresh";
|
||||
import { type RouteConfig } from "sweet";
|
||||
import { define } from "../utils.ts";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
@@ -128,7 +128,7 @@ You can also skip inherited layouts from within a layout file itself. This is
|
||||
useful when a section of your site needs a completely different shell:
|
||||
|
||||
```tsx routes/admin/_layout.tsx
|
||||
import { type LayoutConfig } from "fresh";
|
||||
import { type LayoutConfig } from "sweet";
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export const config: LayoutConfig = {
|
||||
|
||||
@@ -7,7 +7,7 @@ Routing defines which middlewares and routes should respond to a particular
|
||||
request.
|
||||
|
||||
```ts main.ts
|
||||
import { App } from "fresh";
|
||||
import { App } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.get("/", () => new Response("hello")) // Responds to: GET /
|
||||
|
||||
@@ -10,7 +10,7 @@ disk for optimal performance with
|
||||
headers.
|
||||
|
||||
```ts main.ts
|
||||
import { staticFiles } from "fresh";
|
||||
import { staticFiles } from "sweet";
|
||||
|
||||
const app = new App()
|
||||
.use(staticFiles());
|
||||
@@ -55,7 +55,7 @@ first directory in the array takes precedence.
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -99,7 +99,7 @@ Use the `asset()` function to add caching headers manually. It will be served
|
||||
with a cache lifetime of one year.
|
||||
|
||||
```tsx routes/about.tsx
|
||||
import { asset } from "fresh/runtime";
|
||||
import { asset } from "sweet/runtime";
|
||||
|
||||
export default function About() {
|
||||
// Adding caching headers manually
|
||||
@@ -110,7 +110,7 @@ export default function About() {
|
||||
For `<img>` tags with a `srcset` attribute, use `assetSrcSet()`:
|
||||
|
||||
```tsx routes/gallery.tsx
|
||||
import { assetSrcSet } from "fresh/runtime";
|
||||
import { assetSrcSet } from "sweet/runtime";
|
||||
|
||||
export default function Gallery() {
|
||||
return (
|
||||
@@ -139,7 +139,7 @@ deno add -D npm:vite-imagetools
|
||||
|
||||
```ts vite.config.ts
|
||||
import { defineConfig } from "vite";
|
||||
import { fresh } from "@fresh/plugin-vite";
|
||||
import { fresh } from "@paulaboks/sweet-vite";
|
||||
import { imagetools } from "vite-imagetools";
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
Reference in New Issue
Block a user