feat: refresh landing page for Fresh 2.3 (#3775)
- Update HelloBar to announce Fresh 2.3 with feature callouts
(WebSockets, View Transitions, Temporal API)
- Rework hero section: new headline ("The framework so simple, you
already know it"), descriptive subtitle, moved CTA to left
- Remove old Simple section, add "Take a tour of Fresh" heading before
showcase
- Add new showcase sections: View Transitions, API Routes/Handlers,
WebSockets, `<Head>` element, OpenTelemetry
- Fix broken Deco showcase image (missing `/showcase/` directory)
- Fix syntax highlighting in Simple section (was using raw `<pre>`
instead of Prism)
- Update RenderingSection to use Temporal API instead of Date API
- Fix cursor styles on Forms and Partials interactive demos
- Move WebSocket docs from Examples to Advanced in TOC
- Densify all showcase sections: smaller headings, code blocks, icons,
demo boxes, arrows, and tighter spacing
---------
Co-authored-by: Josh Collinsworth <joshuajcollinsworth@gmail.com>
This commit is contained in:
co-authored by
Josh Collinsworth
parent
d16172e420
commit
cb6d02d2eb
@@ -176,7 +176,7 @@ export const handler = define.handlers({
|
||||
## WebSockets
|
||||
|
||||
Fresh provides first-class WebSocket support via `ctx.upgrade()`. See the full
|
||||
[WebSocket guide](/docs/examples/websockets) for all options.
|
||||
[WebSocket guide](/docs/advanced/websockets) for all options.
|
||||
|
||||
## Subdomain routing
|
||||
|
||||
|
||||
@@ -13,5 +13,4 @@ that you may like in your Fresh project.
|
||||
- [Sharing state between islands](./examples/sharing-state-between-islands)
|
||||
- [Active links](./examples/active-links)
|
||||
- [Session management](./examples/session-management)
|
||||
- [WebSockets](./examples/websockets)
|
||||
- [Common Patterns](./examples/common-patterns)
|
||||
|
||||
+1
-1
@@ -61,6 +61,7 @@ const toc: RawTableOfContents = {
|
||||
["environment-variables", "Environment Variables", "link:latest"],
|
||||
["head", "<head> element", "link:latest"],
|
||||
["vite", "Vite Plugin Options", "link:latest"],
|
||||
["websockets", "WebSockets", "link:latest"],
|
||||
["opentelemetry", "OpenTelemetry", "link:latest"],
|
||||
["api-reference", "API Reference", "link:latest"],
|
||||
["troubleshooting", "Troubleshooting", "link:latest"],
|
||||
@@ -107,7 +108,6 @@ const toc: RawTableOfContents = {
|
||||
],
|
||||
["active-links", "Active links", "link:latest"],
|
||||
["session-management", "Session management", "link:latest"],
|
||||
["websockets", "WebSockets", "link:latest"],
|
||||
["common-patterns", "Common Patterns", "link:latest"],
|
||||
],
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ export function CodeBlock(
|
||||
) {
|
||||
return (
|
||||
<pre
|
||||
class="rounded-lg text-base leading-relaxed bg-slate-800 text-white p-4 sm:p-6 md:p-4 lg:p-6 2xl:p-8 overflow-x-auto"
|
||||
class="rounded-lg text-sm leading-relaxed bg-slate-800 text-white p-3 sm:p-4 overflow-x-auto"
|
||||
data-language={lang}
|
||||
// deno-lint-ignore react-no-danger
|
||||
><code dangerouslySetInnerHTML={{ __html: Prism.highlight(code, Prism.languages[lang], lang)}} /></pre>
|
||||
|
||||
@@ -14,7 +14,7 @@ export function CodeWindow(props: CodeWindowProps) {
|
||||
style={props.style}
|
||||
>
|
||||
<div class="flex items-stretch justify-start">
|
||||
<div class="p-4 flex items-center">
|
||||
<div class="p-3 flex items-center">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
width="41"
|
||||
@@ -28,7 +28,7 @@ export function CodeWindow(props: CodeWindowProps) {
|
||||
<ellipse cx="35.9134" cy="5" rx="4.99155" ry="5" fill="#26C940" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="p-4 w-full leading-none text-slate-400 text-base font-mono">
|
||||
<div class="p-3 w-full leading-none text-slate-400 text-sm font-mono">
|
||||
{props.name ?? ""}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@ export function PageSection(props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<section
|
||||
id={props.id ?? ""}
|
||||
class={`w-full max-w-screen-xl mx-auto my-16 md:my-24 lg:my-32 px-4 sm:px-8 lg:px-16 2xl:px-0 flex flex-col gap-8 md:gap-16 ${
|
||||
class={`w-full max-w-screen-xl mx-auto my-12 md:my-16 lg:my-24 px-4 sm:px-8 lg:px-16 2xl:px-0 flex flex-col gap-6 md:gap-8 ${
|
||||
props.class ?? ""
|
||||
}`}
|
||||
>
|
||||
|
||||
@@ -26,7 +26,7 @@ export function SideBySide(props: SideBySideProps) {
|
||||
|
||||
return (
|
||||
<div
|
||||
class={`grid grid-cols-1 items-center gap-12 md:gap-16 xl:gap-32 ${
|
||||
class={`grid grid-cols-1 items-center gap-8 md:gap-10 xl:gap-16 ${
|
||||
props.reverseOnDesktop ? "[&>*]:md:first:order-1" : ""
|
||||
} ${mdSplitClass} ${lgSplitClass} ${props.class ?? ""}`}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const apiCode = `import { createDefine } from "fresh";
|
||||
const define = createDefine();
|
||||
|
||||
export const handlers = define.handlers({
|
||||
GET(ctx) {
|
||||
const user = db.getUser(ctx.params.id);
|
||||
return Response.json(user);
|
||||
},
|
||||
POST(ctx) {
|
||||
const body = await ctx.req.json();
|
||||
const user = db.updateUser(ctx.params.id, body);
|
||||
return Response.json(user);
|
||||
},
|
||||
DELETE(ctx) {
|
||||
db.deleteUser(ctx.params.id);
|
||||
return new Response(null, { status: 204 });
|
||||
},
|
||||
});`;
|
||||
|
||||
export function APIRoutesSection() {
|
||||
return (
|
||||
<PageSection>
|
||||
<SideBySide
|
||||
mdColSplit="3/2"
|
||||
lgColSplit="3/2"
|
||||
reverseOnDesktop
|
||||
class="!items-start"
|
||||
>
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-api text-fresh"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>API routes icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M4 13h5" />
|
||||
<path d="M12 16v-8h3a2 2 0 0 1 2 2v1a2 2 0 0 1 -2 2h-3" />
|
||||
<path d="M20 8v8" />
|
||||
<path d="M9 16v-5.5a2.5 2.5 0 0 0 -5 0v5.5" />
|
||||
</svg>
|
||||
<SectionHeading>Handlers for every method</SectionHeading>
|
||||
<p>
|
||||
Define{" "}
|
||||
<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono">
|
||||
GET
|
||||
</code>,{" "}
|
||||
<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono">
|
||||
POST
|
||||
</code>,{" "}
|
||||
<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono">
|
||||
DELETE
|
||||
</code>{" "}
|
||||
— any HTTP method as a named handler on your route. Fresh maps
|
||||
requests to the right function automatically, with full type safety.
|
||||
</p>
|
||||
<FancyLink href="/docs/concepts/routing" class="mt-2">
|
||||
Learn about handlers
|
||||
</FancyLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<CodeWindow name="routes/users/[id].tsx">
|
||||
<CodeBlock code={apiCode} lang="js" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</SideBySide>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export function DemoBox(props: DemoBoxProps) {
|
||||
const innerFlip = props.flip ? "skew-y-2 skew-x-3" : "-skew-y-2 -skew-x-3";
|
||||
return (
|
||||
<div
|
||||
class={`bg-gradient-to-br font-medium from-blue-200 via-green-300 to-yellow-200 p-8 py-12 text-center items-center flex justify-center ${outerFlip}`}
|
||||
class={`bg-gradient-to-br font-medium from-blue-200 via-green-300 to-yellow-200 p-5 py-8 text-center items-center flex justify-center text-sm ${outerFlip}`}
|
||||
>
|
||||
<div class={`w-full ${innerFlip}`}>
|
||||
{props.children}
|
||||
|
||||
@@ -13,7 +13,7 @@ export function ExampleArrow(
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xml:space="preserve"
|
||||
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"
|
||||
class={`w-12 -my-8 relative z-10 mx-auto ${props?.class ?? ""}`}
|
||||
class={`w-8 -my-6 relative z-10 mx-auto ${props?.class ?? ""}`}
|
||||
>
|
||||
<path
|
||||
d="M50.704,18c46.89,80.967 38.288,189.344 5.941,254.255"
|
||||
|
||||
@@ -8,14 +8,14 @@ import { ExampleArrow } from "../homepage/ExampleArrow.tsx";
|
||||
import { FancyLink } from "../FancyLink.tsx";
|
||||
import { FormSubmitDemo } from "../../islands/FormSubmitDemo.tsx";
|
||||
|
||||
const routingCode = `import { define } from "../utils.ts";
|
||||
const routingCode = `import { createDefine } from "fresh";
|
||||
const define = createDefine();
|
||||
|
||||
export const handler = define.handlers({
|
||||
async POST(ctx) {
|
||||
const form = await ctx.req.formData();
|
||||
|
||||
// Do something with the form data here,
|
||||
// then redirect user to thank you page
|
||||
const treat = form.get("treat");
|
||||
await db.votes.insert({ treat });
|
||||
|
||||
return new Response(null, {
|
||||
status: 303,
|
||||
@@ -34,8 +34,8 @@ export function FormsSection() {
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-route-square-2 text-fresh"
|
||||
width="4rem"
|
||||
height="4rem"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
@@ -49,17 +49,11 @@ export function FormsSection() {
|
||||
<path d="M17 3h4v4h-4z" />
|
||||
</svg>
|
||||
</div>
|
||||
<SectionHeading>
|
||||
Forms, the right way
|
||||
</SectionHeading>
|
||||
<SectionHeading>Forms that just work</SectionHeading>
|
||||
<p>
|
||||
Don't fight the browser. Fresh helps you handle form submissions and
|
||||
other dynamic requests server-side, from any route.
|
||||
</p>
|
||||
<p>
|
||||
Since Fresh is built on{" "}
|
||||
<a href="https://deno.com" class="underline">Deno</a>, it's built on
|
||||
web standards.
|
||||
Handle submissions server-side with standard Request and FormData.
|
||||
No client-side state management, no serialization headaches.
|
||||
Progressive enhancement comes free.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/forms" class="mt-2">
|
||||
Forms in Fresh
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const headCode = `import { Head } from "fresh/runtime";
|
||||
|
||||
export default function MyPage() {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>My Page</title>
|
||||
<meta name="description" content="..." />
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
</Head>
|
||||
<h1>Hello, world!</h1>
|
||||
</>
|
||||
);
|
||||
}`;
|
||||
|
||||
export function HeadSection() {
|
||||
return (
|
||||
<PageSection>
|
||||
<SideBySide
|
||||
mdColSplit="3/2"
|
||||
lgColSplit="3/2"
|
||||
reverseOnDesktop
|
||||
class="!items-start"
|
||||
>
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-file-code text-fresh"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>Head element icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
||||
<path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" />
|
||||
<path d="M10 13l-1 2l1 2" />
|
||||
<path d="M14 13l1 2l-1 2" />
|
||||
</svg>
|
||||
<SectionHeading>
|
||||
Full control of{" "}
|
||||
<span
|
||||
// deno-lint-ignore react-no-danger
|
||||
dangerouslySetInnerHTML={{ __html: "<head>" }}
|
||||
/>
|
||||
</SectionHeading>
|
||||
<p>
|
||||
Use the{" "}
|
||||
<code
|
||||
class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono"
|
||||
// deno-lint-ignore react-no-danger
|
||||
dangerouslySetInnerHTML={{ __html: "<Head>" }}
|
||||
/>{" "}
|
||||
component from any page or island to set titles, meta tags,
|
||||
stylesheets, and scripts — no hoisting hacks or side channels
|
||||
needed.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/head" class="mt-2">
|
||||
<span
|
||||
// deno-lint-ignore react-no-danger
|
||||
dangerouslySetInnerHTML={{ __html: "Learn about <Head>" }}
|
||||
/>
|
||||
</FancyLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<CodeWindow name="routes/my-page.tsx">
|
||||
<CodeBlock code={headCode} lang="jsx" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</SideBySide>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -9,15 +9,20 @@ export function Hero() {
|
||||
<div class="bg-green-300 mt-0 pt-32 md:pt-48 !mb-0 bg-gradient-to-br from-blue-100 via-green-200 to-yellow-100">
|
||||
<div class="md:grid grid-cols-5 gap-8 md:gap-16 items-center w-full max-w-screen-xl mx-auto px-4 md:px-8 lg:px-16 2xl:px-0">
|
||||
<div class="flex-1 text-center md:text-left md:col-span-3 pb-8 md:pb-32">
|
||||
<p class="italic text-gray-500 text-lg mb-4">Introducing Fresh:</p>
|
||||
<h2 class="text-[calc(1rem+4vw)] leading-tight sm:text-5xl lg:text-6xl sm:tracking-tight sm:leading-none font-extrabold">
|
||||
The simple, approachable, productive web framework
|
||||
The framework so simple, you already know it.
|
||||
</h2>
|
||||
<p class="mt-6 text-lg sm:text-xl text-gray-700 text-balance max-w-prose">
|
||||
No config files, no build step, no node_modules. Just one file and
|
||||
you have a server with routing, JSX, and islands.
|
||||
</p>
|
||||
<div class="mt-12 flex flex-wrap justify-center items-stretch md:justify-start gap-4">
|
||||
<FancyLink href="/docs/getting-started">Get started</FancyLink>
|
||||
<CopyArea code={`deno run -Ar jsr:@fresh/init`} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="md:col-span-2 flex justify-center items-end">
|
||||
<div class="md:col-span-2 flex justify-center items-end pb-8 md:pb-32">
|
||||
<LemonTop />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,8 +40,8 @@ export function IslandsSection() {
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-beach text-fresh"
|
||||
width="4rem"
|
||||
height="4rem"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
@@ -56,17 +56,19 @@ export function IslandsSection() {
|
||||
<path d="M15 9l-3 5.196" />
|
||||
<path d="M3 19.25a2.4 2.4 0 0 1 1 -.25a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 1 .25" />
|
||||
</svg>
|
||||
<SectionHeading>Island-based architecture</SectionHeading>
|
||||
<SectionHeading>Interactive where it matters</SectionHeading>
|
||||
<p>
|
||||
Fresh ships plain HTML to the client, then hydrates with JavaScript
|
||||
only where needed.
|
||||
Most of your page is static HTML. Islands are the small, interactive
|
||||
parts that get hydrated with JavaScript. You choose exactly what
|
||||
runs on the client.
|
||||
</p>
|
||||
<p>
|
||||
Because it's Preact, you get best-in-class performance, plus the
|
||||
convenience of{" "}
|
||||
Built on{" "}
|
||||
<a href="https://preactjs.com/" class="underline">Preact</a> and
|
||||
{" "}
|
||||
<a href="https://preactjs.com/guide/v10/signals/" class="underline">
|
||||
Signals
|
||||
</a>.
|
||||
</a>, so islands are tiny and reactive out of the box.
|
||||
</p>
|
||||
<FancyLink href="/docs/concepts/islands" class="mt-2">
|
||||
Learn more about islands
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
|
||||
const features = [
|
||||
{
|
||||
title: "View Transitions",
|
||||
description:
|
||||
"Native-feeling page transitions with a single config flag. Customize per-element with plain CSS.",
|
||||
href: "/docs/advanced/view-transitions",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M18 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12z" />
|
||||
<path d="M9 12h6" />
|
||||
<path d="M13 8l4 4l-4 4" />
|
||||
</svg>
|
||||
),
|
||||
code: `const app = new App({
|
||||
viewTransition: true,
|
||||
});`,
|
||||
lang: "js" as const,
|
||||
},
|
||||
{
|
||||
title: "Route Handlers",
|
||||
description:
|
||||
"Define GET, POST, DELETE, or any HTTP method as a named handler on your route, with full type safety.",
|
||||
href: "/docs/concepts/routing",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M4 13h5" />
|
||||
<path d="M12 16v-8h3a2 2 0 0 1 2 2v1a2 2 0 0 1 -2 2h-3" />
|
||||
<path d="M20 8v8" />
|
||||
<path d="M9 16v-5.5a2.5 2.5 0 0 0 -5 0v5.5" />
|
||||
</svg>
|
||||
),
|
||||
code: `export const handlers = define.handlers({
|
||||
GET(ctx) { /* ... */ },
|
||||
POST(ctx) { /* ... */ },
|
||||
DELETE(ctx) { /* ... */ },
|
||||
});`,
|
||||
lang: "js" as const,
|
||||
},
|
||||
{
|
||||
title: "WebSockets",
|
||||
description:
|
||||
"Add real-time endpoints with app.ws(). Define open, message, and close handlers in a single object.",
|
||||
href: "/docs/advanced/websockets",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M7 10h14l-4 -4" />
|
||||
<path d="M17 14h-14l4 4" />
|
||||
</svg>
|
||||
),
|
||||
code: `app.ws("/chat", {
|
||||
open(socket) { /* ... */ },
|
||||
message(socket, event) {
|
||||
socket.send(event.data);
|
||||
},
|
||||
});`,
|
||||
lang: "js" as const,
|
||||
},
|
||||
{
|
||||
title: "<Head> Component",
|
||||
description:
|
||||
"Set titles, meta tags, stylesheets, and scripts from any page or island. No hoisting hacks needed.",
|
||||
href: "/docs/advanced/head",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
||||
<path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" />
|
||||
<path d="M10 13l-1 2l1 2" />
|
||||
<path d="M14 13l1 2l-1 2" />
|
||||
</svg>
|
||||
),
|
||||
code: `<Head>
|
||||
<title>My Page</title>
|
||||
<meta name="description"
|
||||
content="..." />
|
||||
</Head>`,
|
||||
lang: "jsx" as const,
|
||||
},
|
||||
{
|
||||
title: "OpenTelemetry",
|
||||
description:
|
||||
"Auto-injects a traceparent meta tag into every page, connecting browser traces to server spans.",
|
||||
href: "/docs/advanced/opentelemetry",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M6 21l6 -5l6 5" />
|
||||
<path d="M12 13v8" />
|
||||
<path d="M3.294 13.678l.166 .281c.52 .88 1.624 1.265 2.605 .91l14.242 -5.165a1.023 1.023 0 0 0 .565 -1.456l-2.62 -4.705a1.024 1.024 0 0 0 -1.462 -.394l-13.397 7.719c-1.038 .598 -1.272 1.783 -.594 2.692" />
|
||||
<path d="M8 11.5l5.5 -3.2" />
|
||||
<path d="M12.602 8.3l-2.552 4.6" />
|
||||
</svg>
|
||||
),
|
||||
code: `const app = new App({
|
||||
otel: true,
|
||||
});`,
|
||||
lang: "js" as const,
|
||||
},
|
||||
{
|
||||
title: "Content Security Policy",
|
||||
description:
|
||||
"Automatic nonce injection for inline scripts and styles. Strong security defaults with zero boilerplate.",
|
||||
href: "/docs/plugins/csp",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.5rem"
|
||||
height="1.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M11.46 20.846a12 12 0 0 1 -7.96 -14.846a12 12 0 0 0 8.5 -3a12 12 0 0 0 8.5 3a12 12 0 0 1 -.09 7.06" />
|
||||
<path d="M15 19l2 2l4 -4" />
|
||||
</svg>
|
||||
),
|
||||
code: `app.use(csp({
|
||||
directives: {
|
||||
scriptSrc: ["'nonce'"],
|
||||
},
|
||||
}));`,
|
||||
lang: "js" as const,
|
||||
},
|
||||
];
|
||||
|
||||
const extras = [
|
||||
{
|
||||
title: "File-based routing",
|
||||
description:
|
||||
"Drop a file in routes/, get a URL. Dynamic params via [id].tsx.",
|
||||
href: "/docs/concepts/file-routing",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
||||
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
||||
<path d="M5 18h2" />
|
||||
<path d="M10 18h2" />
|
||||
<path d="M15 18h2" />
|
||||
<path d="M20 18h2" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Middleware",
|
||||
description: "Chain auth, logging, or any logic before your routes run.",
|
||||
href: "/docs/concepts/middleware",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M12 3l8 4.5v9l-8 4.5l-8 -4.5v-9l8 -4.5" />
|
||||
<path d="M12 12l8 -4.5" />
|
||||
<path d="M12 12v9" />
|
||||
<path d="M12 12l-8 -4.5" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Zero-config TypeScript",
|
||||
description: "Just write .tsx. No tsconfig, no build step, it just works.",
|
||||
href: "/docs/concepts/routing",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M15 17.5c.32 .32 .754 .5 1.207 .5h.543a1.75 1.75 0 0 0 0 -3.5h-1a1.75 1.75 0 0 1 0 -3.5h.543c.453 0 .887 .18 1.207 .5" />
|
||||
<path d="M9 12h4" />
|
||||
<path d="M11 12v6" />
|
||||
<path d="M21 19v-14a2 2 0 0 0 -2 -2h-14a2 2 0 0 0 -2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2 -2z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Deploy anywhere",
|
||||
description:
|
||||
"Deno Deploy, Docker, Cloudflare Workers, or a single binary with deno compile.",
|
||||
href: "/docs/deployment/deno-deploy",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" />
|
||||
<path d="M3.6 9h16.8" />
|
||||
<path d="M3.6 15h16.8" />
|
||||
<path d="M11.5 3a17 17 0 0 0 0 18" />
|
||||
<path d="M12.5 3a17 17 0 0 1 0 18" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Layouts",
|
||||
description:
|
||||
"Nested layouts that compose automatically from the file system.",
|
||||
href: "/docs/concepts/layouts",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M4 4m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v1a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" />
|
||||
<path d="M4 13m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" />
|
||||
<path d="M14 4m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Built-in plugins",
|
||||
description:
|
||||
"CORS, CSRF, IP filtering, and trailing slashes out of the box.",
|
||||
href: "/docs/plugins/cors",
|
||||
icon: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="text-fresh"
|
||||
width="1.25rem"
|
||||
height="1.25rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M4 7l3 0" />
|
||||
<path d="M4 11l3 0" />
|
||||
<path d="M4 15l3 0" />
|
||||
<path d="M4 19l3 0" />
|
||||
<path d="M11 7l10 0" />
|
||||
<path d="M11 11l10 0" />
|
||||
<path d="M11 15l10 0" />
|
||||
<path d="M11 19l10 0" />
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
export function MoreFeatures() {
|
||||
return (
|
||||
<div className="w-full py-8 bg-linear-to-r from-fresh-green/10 to-fresh/10">
|
||||
<PageSection>
|
||||
<div class="text-center flex flex-col gap-2">
|
||||
<SectionHeading>And so much more</SectionHeading>
|
||||
</div>
|
||||
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{features.map((f) => (
|
||||
<a
|
||||
href={f.href}
|
||||
class="grid grid-cols-1 grid-rows-[minmax(9.5rem,auto)_1fr] items-stretch gap-3 transition-colors bg-white rounded-lg overflow-clip hover:bg-fresh/1 border border-gray-200 hover:border-fresh"
|
||||
>
|
||||
<div className="p-6 space-y-3">
|
||||
<div class="flex items-center gap-2 justify-between">
|
||||
<h3 class="font-bold text-lg sm:text-xl lg:text-2xl">
|
||||
{f.title}
|
||||
</h3>
|
||||
{f.icon}
|
||||
</div>
|
||||
<p class="text-gray-600 text-sm">{f.description}</p>
|
||||
</div>
|
||||
<div class="text-xs h-full [&>pre]:m-0! [&>pre]:rounded-none [&>pre]:h-full [&>pre]:p-6! flex-1">
|
||||
<CodeBlock code={f.code} lang={f.lang} />
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div class="text-center flex flex-col gap-2 mt-8">
|
||||
<h3 class="text-lg font-bold text-gray-600">(…and even more)</h3>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-4">
|
||||
{extras.map((e) => (
|
||||
<a
|
||||
href={e.href}
|
||||
class="flex flex-col gap-2 p-4 rounded-lg border border-gray-200 hover:bg-fresh/1 transition-colors bg-white hover:border-fresh"
|
||||
>
|
||||
<div class="flex items-center gap-2 justify-between">
|
||||
<h3 class="font-bold text-sm">{e.title}</h3>
|
||||
{e.icon}
|
||||
</div>
|
||||
<p class="text-gray-500 text-xs">{e.description}</p>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</PageSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -45,8 +45,8 @@ export function PartialsSection() {
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-arrows-transfer-down text-fresh"
|
||||
width="4rem"
|
||||
height="4rem"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
@@ -66,9 +66,10 @@ export function PartialsSection() {
|
||||
|
||||
<SectionHeading>Stream HTML straight from the server</SectionHeading>
|
||||
<p>
|
||||
Fresh Partials let you fetch HTML and slot it directly into the
|
||||
page, without a full page reload - perfect for interactive elements
|
||||
and dynamic apps.
|
||||
Swap chunks of HTML from the server straight into the page. No full
|
||||
reload, no client-side routing library. Click a link or submit a
|
||||
form and Fresh streams just the part that changed. Perfect for
|
||||
interactive elements and dynamic apps.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/partials" class="mt-4">
|
||||
Learn more about Partials
|
||||
|
||||
@@ -3,16 +3,28 @@ import { Partial } from "fresh/runtime";
|
||||
export const RecipeDemo = () => (
|
||||
<div
|
||||
f-client-nav
|
||||
class="w-full grid grid-cols-1 md:grid-cols-[auto_1fr] text-left gap-6 items-stretch min-h-64"
|
||||
class="w-full grid grid-cols-1 md:grid-cols-[auto_1fr] text-left gap-6 items-stretch min-h-40"
|
||||
>
|
||||
<aside class="flex flex-col gap-2 underline p-6 pl-0 border-b md:border-r md:border-b-0 border-current text-left items-start justify-center">
|
||||
<button type="button" f-partial="/recipes/lemonade">
|
||||
<button
|
||||
type="button"
|
||||
f-partial="/recipes/lemonade"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
Lemonade
|
||||
</button>
|
||||
<button type="button" f-partial="/recipes/lemon-honey-tea">
|
||||
<button
|
||||
type="button"
|
||||
f-partial="/recipes/lemon-honey-tea"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
Lemon-honey tea
|
||||
</button>
|
||||
<button type="button" f-partial="/recipes/lemondrop">
|
||||
<button
|
||||
type="button"
|
||||
f-partial="/recipes/lemondrop"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
Lemondrop Martini
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
@@ -7,9 +7,10 @@ import { DemoBox } from "../../components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "../../components/homepage/ExampleArrow.tsx";
|
||||
|
||||
const serverCode = `export default function HomePage() {
|
||||
const time = new Date().toLocaleString();
|
||||
const now = Temporal.Now.plainDateTimeISO()
|
||||
.toLocaleString("en-US");
|
||||
return (
|
||||
<p>Freshly server-rendered {time}</p>
|
||||
<p>Freshly server-rendered {now}</p>
|
||||
);
|
||||
}`;
|
||||
|
||||
@@ -22,8 +23,8 @@ export function RenderingSection() {
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-atom text-fresh"
|
||||
width="4rem"
|
||||
height="4rem"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
@@ -38,16 +39,13 @@ export function RenderingSection() {
|
||||
<path d="M19.071 4.929c-1.562 -1.562 -6 .337 -9.9 4.243c-3.905 3.905 -5.804 8.337 -4.242 9.9c1.562 1.561 6 -.338 9.9 -4.244c3.905 -3.905 5.804 -8.337 4.242 -9.9" />
|
||||
<path d="M4.929 4.929c-1.562 1.562 .337 6 4.243 9.9c3.905 3.905 8.337 5.804 9.9 4.242c1.561 -1.562 -.338 -6 -4.244 -9.9c-3.905 -3.905 -8.337 -5.804 -9.9 -4.242" />
|
||||
</svg>
|
||||
<SectionHeading>
|
||||
Build fast apps fast
|
||||
</SectionHeading>
|
||||
<SectionHeading>Server-rendered by default</SectionHeading>
|
||||
<p>
|
||||
Fresh routes are dynamically server-rendered{" "}
|
||||
Every route renders on the server as a{" "}
|
||||
<a href="https://preactjs.com/" class="underline">Preact</a>{" "}
|
||||
components, so there's zero JavaScript shipped to the browser by
|
||||
default.
|
||||
component. Zero JavaScript hits the browser unless you opt in with
|
||||
an island. Pages are fast because they start as plain HTML.
|
||||
</p>
|
||||
<p>Simple to write; fast to run.</p>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<CodeWindow name="routes/index.tsx">
|
||||
@@ -56,10 +54,8 @@ export function RenderingSection() {
|
||||
<ExampleArrow class="ml-[55%]" />{" "}
|
||||
<DemoBox>
|
||||
<p>
|
||||
Freshly server-rendered {new Date().toLocaleString("default", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "medium",
|
||||
})} UTC
|
||||
Freshly server-rendered{" "}
|
||||
{Temporal.Now.plainDateTimeISO().toLocaleString("en-US")}
|
||||
</p>
|
||||
</DemoBox>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@ export function SectionHeading(
|
||||
{ children }: { children: ComponentChildren },
|
||||
) {
|
||||
return (
|
||||
<h2 class="text-3xl lg:text-4xl xl:text-5xl text-gray-600 font-[750] text-balance">
|
||||
<h2 class="text-2xl lg:text-3xl xl:text-4xl text-gray-600 font-[750] text-balance">
|
||||
{children}
|
||||
</h2>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const otelCode = `import { App } from "fresh";
|
||||
|
||||
// When OpenTelemetry is active, Fresh
|
||||
// auto-injects a <meta name="traceparent">
|
||||
// tag — connecting browser traces to
|
||||
// server spans, zero config required
|
||||
const app = new App();
|
||||
|
||||
app.listen();`;
|
||||
|
||||
export function SecuritySection() {
|
||||
return (
|
||||
<PageSection>
|
||||
<SideBySide mdColSplit="2/3" lgColSplit="2/3" class="!items-start">
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-telescope text-fresh"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>Observability icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M6 21l6 -5l6 5" />
|
||||
<path d="M12 13v8" />
|
||||
<path d="M3.294 13.678l.166 .281c.52 .88 1.624 1.265 2.605 .91l14.242 -5.165a1.023 1.023 0 0 0 .565 -1.456l-2.62 -4.705a1.024 1.024 0 0 0 -1.462 -.394l-13.397 7.719c-1.038 .598 -1.272 1.783 -.594 2.692" />
|
||||
<path d="M8 11.5l5.5 -3.2" />
|
||||
<path d="M12.602 8.3l-2.552 4.6" />
|
||||
</svg>
|
||||
<SectionHeading>OpenTelemetry, built in</SectionHeading>
|
||||
<p>
|
||||
When OpenTelemetry is active, Fresh automatically injects a{" "}
|
||||
<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono">
|
||||
traceparent
|
||||
</code>{" "}
|
||||
meta tag into every page — connecting your browser traces to server
|
||||
spans end-to-end, zero config required.
|
||||
</p>
|
||||
<p>
|
||||
Get full-stack observability across your entire request lifecycle
|
||||
with zero configuration.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/opentelemetry" class="mt-2">
|
||||
Learn about OpenTelemetry
|
||||
</FancyLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-6">
|
||||
<CodeWindow name="main.ts">
|
||||
<CodeBlock code={otelCode} lang="js" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</SideBySide>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -1,31 +1,40 @@
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
|
||||
const ONE_FILE_EXAMPLE = `import { App } from "fresh";
|
||||
const TRADITIONAL = `// package.json
|
||||
// tsconfig.json
|
||||
// next.config.js
|
||||
// postcss.config.js
|
||||
// tailwind.config.js
|
||||
// .eslintrc.json
|
||||
// app/layout.tsx
|
||||
// app/page.tsx
|
||||
|
||||
const app = new App()
|
||||
.get("/", () => new Response("Hello, World!"));
|
||||
// app/api/hello/route.ts
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
app.listen();`;
|
||||
|
||||
const ADD_JSX_EXAMPLE = `import { App } from "fresh";
|
||||
|
||||
const app = new App()
|
||||
.get("/", (ctx) => ctx.render(<h1>Hello!</h1>));
|
||||
|
||||
app.listen();`;
|
||||
|
||||
const ADD_ISLAND_EXAMPLE = `// islands/Counter.tsx
|
||||
import { useSignal } from "@preact/signals";
|
||||
|
||||
export function Counter() {
|
||||
const count = useSignal(0);
|
||||
return (
|
||||
<button onClick={() => count.value++}>
|
||||
Count: {count}
|
||||
</button>
|
||||
);
|
||||
export async function GET() {
|
||||
return NextResponse.json({
|
||||
message: "Hello!",
|
||||
});
|
||||
}`;
|
||||
|
||||
const FRESH_EXAMPLE = `// main.ts — that's it.
|
||||
import { App } from "fresh";
|
||||
|
||||
const app = new App()
|
||||
.get("/", (ctx) =>
|
||||
ctx.render(<h1>Hello!</h1>)
|
||||
)
|
||||
.get("/api/hello", () =>
|
||||
Response.json({
|
||||
message: "Hello!",
|
||||
})
|
||||
);
|
||||
|
||||
app.listen();`;
|
||||
|
||||
export function Simple() {
|
||||
return (
|
||||
<PageSection class="!mb-12 !mt-20">
|
||||
@@ -35,50 +44,29 @@ export function Simple() {
|
||||
The framework so simple, you already know it.
|
||||
</h2>
|
||||
<p class="text-xl text-balance max-w-prose mx-auto">
|
||||
Fresh is designed to be easy to use by building on the best well-known
|
||||
tools, conventions, and web standards.
|
||||
No config files, no build step, no node_modules. Just one file and you
|
||||
have a server with routing, JSX, and islands.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-3 gap-6 mt-8">
|
||||
<StepCard
|
||||
step="1"
|
||||
title="One file. That's it."
|
||||
description="No config files, no build step, no node_modules. Just one file and you have a server."
|
||||
code={ONE_FILE_EXAMPLE}
|
||||
/>
|
||||
<StepCard
|
||||
step="2"
|
||||
title="Add JSX"
|
||||
description="Render HTML with JSX. Server-side by default, fast by design."
|
||||
code={ADD_JSX_EXAMPLE}
|
||||
/>
|
||||
<StepCard
|
||||
step="3"
|
||||
title="Sprinkle interactivity"
|
||||
description="Add islands for client-side JS only where you need it. Zero JS shipped by default."
|
||||
code={ADD_ISLAND_EXAMPLE}
|
||||
/>
|
||||
<div class="grid md:grid-cols-2 gap-6 mt-8 items-start">
|
||||
<div class="flex flex-col gap-3">
|
||||
<h3 class="font-bold text-lg text-gray-400 text-center">
|
||||
The traditional way
|
||||
</h3>
|
||||
<CodeWindow name="8 config files + app code">
|
||||
<CodeBlock code={TRADITIONAL} lang="js" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3">
|
||||
<h3 class="font-bold text-lg text-green-700 text-center">
|
||||
The Fresh way
|
||||
</h3>
|
||||
<CodeWindow name="main.ts">
|
||||
<CodeBlock code={FRESH_EXAMPLE} lang="jsx" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</div>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
|
||||
function StepCard(
|
||||
props: { step: string; title: string; description: string; code: string },
|
||||
) {
|
||||
return (
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="bg-green-200 text-green-800 text-sm font-bold rounded-full w-7 h-7 flex items-center justify-center">
|
||||
{props.step}
|
||||
</span>
|
||||
<h3 class="font-bold text-lg">{props.title}</h3>
|
||||
</div>
|
||||
<p class="text-gray-600 text-sm">{props.description}</p>
|
||||
<pre class="bg-slate-800 text-green-100 rounded-md p-4 text-sm overflow-x-auto flex-1">
|
||||
<code>{props.code}</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ export function SocialProof() {
|
||||
<a href="https://deno.com/blog/deco-cx-subhosting-serve-their-clients-storefronts-fast">
|
||||
<img
|
||||
src="/showcase/deco.webp"
|
||||
alt="Deco CX"
|
||||
class="mx-auto"
|
||||
alt="Deco.cx screenshot"
|
||||
class="mx-auto max-w-screen-md w-full"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const transitionCode = `import { App } from "fresh";
|
||||
|
||||
const app = new App({
|
||||
// Enable the View Transitions API
|
||||
// for smooth client-side navigation
|
||||
viewTransition: true,
|
||||
});
|
||||
|
||||
app.listen();`;
|
||||
|
||||
const cssCode = `/* Style your transitions with CSS */
|
||||
::view-transition-old(root) {
|
||||
animation: fade-out 0.2s ease-in;
|
||||
}
|
||||
::view-transition-new(root) {
|
||||
animation: fade-in 0.2s ease-out;
|
||||
}`;
|
||||
|
||||
export function TransitionsSection() {
|
||||
return (
|
||||
<PageSection>
|
||||
<SideBySide mdColSplit="2/3" lgColSplit="2/3" class="!items-start">
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-transition-right text-fresh"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>View Transitions icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M18 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12z" />
|
||||
<path d="M9 12h6" />
|
||||
<path d="M13 8l4 4l-4 4" />
|
||||
</svg>
|
||||
<SectionHeading>Smooth View Transitions</SectionHeading>
|
||||
<p>
|
||||
Fresh supports the{" "}
|
||||
<a
|
||||
href="https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API"
|
||||
class="underline"
|
||||
>
|
||||
View Transitions API
|
||||
</a>{" "}
|
||||
out of the box, giving your app native-feeling page transitions with
|
||||
a single config flag.
|
||||
</p>
|
||||
<p>
|
||||
Pages crossfade automatically. Customize animations per-element with
|
||||
plain CSS — no JavaScript animation libraries needed.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/view-transitions" class="mt-2">
|
||||
Learn about View Transitions
|
||||
</FancyLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<CodeWindow name="main.ts">
|
||||
<CodeBlock code={transitionCode} lang="js" />
|
||||
</CodeWindow>
|
||||
<CodeWindow name="styles.css">
|
||||
<CodeBlock code={cssCode} lang="js" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</SideBySide>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const wsCode = `import { App } from "fresh";
|
||||
|
||||
const app = new App();
|
||||
|
||||
app.ws("/chat", {
|
||||
open(socket) {
|
||||
console.log("Client connected");
|
||||
},
|
||||
message(socket, event) {
|
||||
// Echo the message back
|
||||
socket.send(\`You said: \${event.data}\`);
|
||||
},
|
||||
close(socket) {
|
||||
console.log("Client disconnected");
|
||||
},
|
||||
});
|
||||
|
||||
app.listen();`;
|
||||
|
||||
export function WebSocketSection() {
|
||||
return (
|
||||
<PageSection>
|
||||
<SideBySide mdColSplit="2/3" lgColSplit="2/3" class="!items-start">
|
||||
<div class="flex flex-col gap-4 md:sticky md:top-4">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="icon icon-tabler icon-tabler-arrows-exchange text-fresh"
|
||||
width="2.5rem"
|
||||
height="2.5rem"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<title>WebSocket icon</title>
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M7 10h14l-4 -4" />
|
||||
<path d="M17 14h-14l4 4" />
|
||||
</svg>
|
||||
<SectionHeading>First-class WebSockets</SectionHeading>
|
||||
<p>
|
||||
Add real-time endpoints with{" "}
|
||||
<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono">
|
||||
app.ws()
|
||||
</code>{" "}
|
||||
— define open, message, and close handlers in a single object. Build
|
||||
chat, live dashboards, or collaborative editing without leaving
|
||||
Fresh.
|
||||
</p>
|
||||
<FancyLink href="/docs/advanced/websockets" class="mt-2">
|
||||
Learn about WebSockets
|
||||
</FancyLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<CodeWindow name="main.ts">
|
||||
<CodeBlock code={wsCode} lang="js" />
|
||||
</CodeWindow>
|
||||
</div>
|
||||
</SideBySide>
|
||||
</PageSection>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,10 @@ export function FormSubmitDemo() {
|
||||
<fieldset class="mb-4">
|
||||
<legend class="mb-2 font-bold">What's your favorite treat?</legend>
|
||||
|
||||
<label for="lemon-meringue-pie" class="flex gap-2 items-center">
|
||||
<label
|
||||
for="lemon-meringue-pie"
|
||||
class="flex gap-2 items-center cursor-pointer"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
value="lemon-meringue-pie"
|
||||
@@ -14,7 +17,10 @@ export function FormSubmitDemo() {
|
||||
/>
|
||||
Lemon meringue pie
|
||||
</label>
|
||||
<label for="lemon-shortbread-cookies" class="flex gap-2 items-center">
|
||||
<label
|
||||
for="lemon-shortbread-cookies"
|
||||
class="flex gap-2 items-center cursor-pointer"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
value="lemon-shortbread-cookies"
|
||||
@@ -23,7 +29,10 @@ export function FormSubmitDemo() {
|
||||
/>
|
||||
Lemon shortbread cookies
|
||||
</label>
|
||||
<label for="lemon-sherbet" class="flex gap-2 items-center">
|
||||
<label
|
||||
for="lemon-sherbet"
|
||||
class="flex gap-2 items-center cursor-pointer"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
value="lemon-sherbet"
|
||||
@@ -32,7 +41,7 @@ export function FormSubmitDemo() {
|
||||
/>
|
||||
Lemon sherbet
|
||||
</label>
|
||||
<label for="lemon-bars" class="flex gap-2 items-center">
|
||||
<label for="lemon-bars" class="flex gap-2 items-center cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
value="lemon-bars"
|
||||
@@ -46,7 +55,7 @@ export function FormSubmitDemo() {
|
||||
<button
|
||||
type="submit"
|
||||
value="Submit"
|
||||
class="pt-2 pb-1 px-3 rounded-sm border-current border-[1.5px] font-semibold"
|
||||
class="pt-2 pb-1 px-3 rounded-sm border-current border-[1.5px] font-semibold cursor-pointer"
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
|
||||
+13
-6
@@ -9,8 +9,8 @@ import { IslandsSection } from "../components/homepage/IslandsSection.tsx";
|
||||
import { PartialsSection } from "../components/homepage/PartialsSection.tsx";
|
||||
import { RenderingSection } from "../components/homepage/RenderingSection.tsx";
|
||||
import { FormsSection } from "../components/homepage/FormsSection.tsx";
|
||||
import { Simple } from "../components/homepage/Simple.tsx";
|
||||
import { SocialProof } from "../components/homepage/SocialProof.tsx";
|
||||
import { MoreFeatures } from "../components/homepage/MoreFeatures.tsx";
|
||||
import { DenoSection } from "../components/homepage/DenoSection.tsx";
|
||||
import { define } from "../utils/state.ts";
|
||||
|
||||
@@ -56,11 +56,14 @@ export default define.page<typeof handler>(function MainPage() {
|
||||
</div>
|
||||
<div class="flex flex-col -mt-20 relative">
|
||||
<Hero />
|
||||
<Simple />
|
||||
<h2 class="text-3xl sm:text-4xl md:text-5xl text-gray-600 font-extrabold text-center mt-8 md:mt-12 lg:mt-16 px-4 italic">
|
||||
Take a tour of Fresh
|
||||
</h2>
|
||||
<RenderingSection />
|
||||
<IslandsSection />
|
||||
<FormsSection />
|
||||
<PartialsSection />
|
||||
<MoreFeatures />
|
||||
<SocialProof />
|
||||
<DenoSection />
|
||||
<CTA />
|
||||
@@ -73,11 +76,15 @@ export default define.page<typeof handler>(function MainPage() {
|
||||
function HelloBar() {
|
||||
return (
|
||||
<a
|
||||
class="bg-gradient-to-r from-blue-200 to-yellow-200 via-green-300 text-black border-b border-green-400 p-4 text-center group"
|
||||
href="https://deno.com/blog/fresh-and-vite"
|
||||
class="bg-gradient-to-r from-blue-200 to-yellow-200 via-green-300 text-black border-b border-green-400 px-4 py-3 text-center group flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-3"
|
||||
href="https://deno.com/blog/fresh-2.3"
|
||||
>
|
||||
Fresh 2 <b>released with Vite</b>{" "}
|
||||
<span class="group-hover:underline">→</span>
|
||||
<span class="font-bold">Fresh 2.3 is here!</span>
|
||||
<span class="hidden sm:inline">—</span>
|
||||
<span class="text-sm sm:text-base">
|
||||
WebSockets, View Transitions, Temporal API, and more{" "}
|
||||
<span class="group-hover:underline">→</span>
|
||||
</span>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
Reference in New Issue
Block a user