@@ -1,4 +1,4 @@
|
||||
import Prism from "$prism";
|
||||
import Prism from "https://esm.sh/prismjs@1.29.0";
|
||||
|
||||
export function CodeBlock(
|
||||
{ code, lang }: { code: string; lang: "js" | "ts" | "jsx" | "md" | "bash" },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
interface CodeWindowProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
||||
name?: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {
|
||||
import type {
|
||||
TableOfContentsCategory,
|
||||
TableOfContentsCategoryEntry,
|
||||
} from "../data/docs.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ComponentChildren } from "preact";
|
||||
import type { ComponentChildren } from "preact";
|
||||
|
||||
export function FancyLink(
|
||||
props: { href: string; children: ComponentChildren; class?: string },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
const LINKS = [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
export function PageSection(props: JSX.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact/jsx-runtime";
|
||||
import type { JSX } from "preact/jsx-runtime";
|
||||
|
||||
type ColumnConfiguration = "1/1" | "2/3" | "3/2";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import { FancyLink } from "../FancyLink.tsx";
|
||||
|
||||
export function CTA() {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
interface DemoBoxProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
||||
flip?: boolean;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import { SideBySide } from "$fresh/www/components/SideBySide.tsx";
|
||||
import { SectionHeading } from "$fresh/www/components/homepage/SectionHeading.tsx";
|
||||
import { PageSection } from "../PageSection.tsx";
|
||||
import { FancyLink } from "../FancyLink.tsx";
|
||||
import { SideBySide } from "../SideBySide.tsx";
|
||||
import { SectionHeading } from "../homepage/SectionHeading.tsx";
|
||||
|
||||
export function DenoSection() {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
export function ExampleArrow(
|
||||
props: JSX.HTMLAttributes<HTMLDivElement>,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { SideBySide } from "$fresh/www/components/SideBySide.tsx";
|
||||
import { CodeWindow } from "$fresh/www/components/CodeWindow.tsx";
|
||||
import { CodeBlock } from "$fresh/www/components/CodeBlock.tsx";
|
||||
import { SectionHeading } from "$fresh/www/components/homepage/SectionHeading.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "$fresh/www/components/homepage/ExampleArrow.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import { PageSection } from "../PageSection.tsx";
|
||||
import { SideBySide } from "../SideBySide.tsx";
|
||||
import { CodeWindow } from "../CodeWindow.tsx";
|
||||
import { CodeBlock } from "../CodeBlock.tsx";
|
||||
import { SectionHeading } from "../homepage/SectionHeading.tsx";
|
||||
import { DemoBox } from "../homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "../homepage/ExampleArrow.tsx";
|
||||
import { FancyLink } from "../FancyLink.tsx";
|
||||
import { FormSubmitDemo } from "../../islands/FormSubmitDemo.tsx";
|
||||
|
||||
const routingCode = `import { Handlers } from "$fresh/server.ts";
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import CopyArea from "../../islands/CopyArea.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import LemonDrop from "$fresh/www/islands/LemonDrop.tsx";
|
||||
import LemonTop from "$fresh/www/islands/LemonTop.tsx";
|
||||
import LemonBottom from "$fresh/www/islands/LemonBottom.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
import LemonTop from "../../islands/LemonTop.tsx";
|
||||
import LemonBottom from "../../islands/LemonBottom.tsx";
|
||||
|
||||
export function Hero(props: { origin: string }) {
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Counter from "$fresh/www/islands/Counter.tsx";
|
||||
import { CodeBlock } from "$fresh/www/components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "$fresh/www/components/CodeWindow.tsx";
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { SideBySide } from "$fresh/www/components/SideBySide.tsx";
|
||||
import { SectionHeading } from "$fresh/www/components/homepage/SectionHeading.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "$fresh/www/components/homepage/ExampleArrow.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import Counter from "../../islands/Counter.tsx";
|
||||
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 { DemoBox } from "../../components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "../../components/homepage/ExampleArrow.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const islandCode = `import { useSignal } from "@preact/signals";
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import Counter from "$fresh/www/islands/Counter.tsx";
|
||||
import { CodeBlock } from "$fresh/www/components/CodeBlock.tsx";
|
||||
import { CodeWindow } from "$fresh/www/components/CodeWindow.tsx";
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { SideBySide } from "$fresh/www/components/SideBySide.tsx";
|
||||
import { SectionHeading } from "$fresh/www/components/homepage/SectionHeading.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "$fresh/www/components/homepage/ExampleArrow.tsx";
|
||||
import { RecipeDemo } from "$fresh/www/components/homepage/RecipeDemo.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
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 { DemoBox } from "../../components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "../../components/homepage/ExampleArrow.tsx";
|
||||
import { RecipeDemo } from "../../components/homepage/RecipeDemo.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
|
||||
const islandCode = `import { Partial } from "$fresh/runtime.ts";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { Partial } from "@fresh/core/runtime";
|
||||
|
||||
export const RecipeDemo = () => (
|
||||
<div
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { SideBySide } from "$fresh/www/components/SideBySide.tsx";
|
||||
import { CodeWindow } from "$fresh/www/components/CodeWindow.tsx";
|
||||
import { CodeBlock } from "$fresh/www/components/CodeBlock.tsx";
|
||||
import { SectionHeading } from "$fresh/www/components/homepage/SectionHeading.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { ExampleArrow } from "$fresh/www/components/homepage/ExampleArrow.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { SideBySide } from "../../components/SideBySide.tsx";
|
||||
import { CodeWindow } from "../../components/CodeWindow.tsx";
|
||||
import { CodeBlock } from "../../components/CodeBlock.tsx";
|
||||
import { SectionHeading } from "../../components/homepage/SectionHeading.tsx";
|
||||
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();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ComponentChildren } from "preact";
|
||||
import type { ComponentChildren } from "preact";
|
||||
|
||||
export function SectionHeading(
|
||||
{ children }: { children: ComponentChildren },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
|
||||
export function Simple() {
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { FancyLink } from "$fresh/www/components/FancyLink.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { PageSection } from "../../components/PageSection.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
import { DemoBox } from "../../components/homepage/DemoBox.tsx";
|
||||
|
||||
export function SocialProof() {
|
||||
return (
|
||||
|
||||
+28
-10
@@ -7,22 +7,40 @@
|
||||
"preview": "deno run -A main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"$fresh/": "../",
|
||||
"preact": "https://esm.sh/preact@10.22.0",
|
||||
"preact/": "https://esm.sh/preact@10.22.0/",
|
||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
|
||||
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.5.1",
|
||||
"$prism": "https://esm.sh/prismjs@1.29.0",
|
||||
"$prism/": "https://esm.sh/prismjs@1.29.0/",
|
||||
"$std/": "https://deno.land/std@0.216.0/",
|
||||
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
|
||||
"$marked-mangle": "https://esm.sh/marked-mangle@1.1.7",
|
||||
"$std/": "https://deno.land/std@0.216.0/",
|
||||
"@fresh/core": "../src/mod.ts",
|
||||
"@fresh/core/client": "../src/runtime/client/mod.tsx",
|
||||
"@fresh/core/client-dev": "../src/runtime/client/dev.ts",
|
||||
"@fresh/core/dev": "../src/dev/mod.ts",
|
||||
"@fresh/core/runtime": "../src/runtime/shared.ts",
|
||||
"@fresh/plugin-tailwind": "../plugin-tailwindcss/src/mod.ts",
|
||||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3",
|
||||
"@preact/signals": "npm:@preact/signals@^1.2.3",
|
||||
"@std/crypto": "jsr:@std/crypto",
|
||||
"@std/datetime": "jsr:@std/datetime@^0.224.0",
|
||||
"@std/encoding": "jsr:@std/encoding",
|
||||
"@std/fmt": "jsr:@std/fmt",
|
||||
"@std/fs": "jsr:@std/fs",
|
||||
"@std/html": "jsr:@std/html@^0.224.0",
|
||||
"@std/jsonc": "jsr:@std/jsonc@^0.221.0",
|
||||
"@std/media-types": "jsr:@std/media-types@^0.221.0",
|
||||
"@std/path": "jsr:@std/path",
|
||||
"@std/semver": "jsr:@std/semver@^0.224.0",
|
||||
"autoprefixer": "npm:autoprefixer@10.4.17",
|
||||
"cssnano": "npm:cssnano@6.0.3",
|
||||
"esbuild": "npm:esbuild@0.20.2",
|
||||
"esbuild-wasm": "npm:esbuild-wasm@0.20.2",
|
||||
"postcss": "npm:postcss@8.4.35",
|
||||
"preact": "npm:preact@^10.22.0",
|
||||
"preact-render-to-string": "npm:preact-render-to-string@^6.4.2",
|
||||
"tailwindcss": "npm:tailwindcss@3.4.1",
|
||||
"tailwindcss/": "npm:/tailwindcss@3.4.1/",
|
||||
"tailwindcss/plugin": "npm:/tailwindcss@3.4.1/plugin.js"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
"jsxImportSource": "preact",
|
||||
"jsxPrecompileSkipElements": ["a", "img", "source", "body", "html", "head"]
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -1,6 +1,14 @@
|
||||
#!/usr/bin/env -S deno run -A --watch=static/,routes/
|
||||
|
||||
import dev from "$fresh/dev.ts";
|
||||
import config from "./fresh.config.ts";
|
||||
import { Builder } from "@fresh/core/dev";
|
||||
import { app } from "./main.ts";
|
||||
import { tailwind } from "@fresh/plugin-tailwind";
|
||||
|
||||
await dev(import.meta.url, "./main.ts", config);
|
||||
const builder = new Builder({ target: "safari12" });
|
||||
tailwind(builder, app, {});
|
||||
|
||||
if (Deno.args.includes("build")) {
|
||||
await builder.build(app);
|
||||
} else {
|
||||
await builder.listen(app);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { defineConfig } from "$fresh/server.ts";
|
||||
import tailwind from "$fresh/plugins/tailwind.ts";
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
target: "safari12",
|
||||
},
|
||||
plugins: [tailwind()],
|
||||
});
|
||||
@@ -1,65 +0,0 @@
|
||||
// DO NOT EDIT. This file is generated by Fresh.
|
||||
// This file SHOULD be checked into source version control.
|
||||
// This file is automatically updated during development when running `dev.ts`.
|
||||
|
||||
import * as $_404 from "./routes/_404.tsx";
|
||||
import * as $_500 from "./routes/_500.tsx";
|
||||
import * as $_app from "./routes/_app.tsx";
|
||||
import * as $_middleware from "./routes/_middleware.ts";
|
||||
import * as $docs_slug_ from "./routes/docs/[...slug].tsx";
|
||||
import * as $docs_middleware from "./routes/docs/_middleware.ts";
|
||||
import * as $docs_index from "./routes/docs/index.tsx";
|
||||
import * as $index from "./routes/index.tsx";
|
||||
import * as $raw from "./routes/raw.ts";
|
||||
import * as $recipes_layout from "./routes/recipes/_layout.tsx";
|
||||
import * as $recipes_lemon_honey_tea from "./routes/recipes/lemon-honey-tea.tsx";
|
||||
import * as $recipes_lemonade from "./routes/recipes/lemonade.tsx";
|
||||
import * as $recipes_lemondrop from "./routes/recipes/lemondrop.tsx";
|
||||
import * as $showcase from "./routes/showcase.tsx";
|
||||
import * as $thanks from "./routes/thanks.tsx";
|
||||
import * as $update from "./routes/update.tsx";
|
||||
import * as $CopyArea from "./islands/CopyArea.tsx";
|
||||
import * as $Counter from "./islands/Counter.tsx";
|
||||
import * as $FormSubmitDemo from "./islands/FormSubmitDemo.tsx";
|
||||
import * as $LemonBottom from "./islands/LemonBottom.tsx";
|
||||
import * as $LemonDrop from "./islands/LemonDrop.tsx";
|
||||
import * as $LemonTop from "./islands/LemonTop.tsx";
|
||||
import * as $SearchButton from "./islands/SearchButton.tsx";
|
||||
import * as $TableOfContents from "./islands/TableOfContents.tsx";
|
||||
import * as $VersionSelect from "./islands/VersionSelect.tsx";
|
||||
import type { Manifest } from "$fresh/server.ts";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/_404.tsx": $_404,
|
||||
"./routes/_500.tsx": $_500,
|
||||
"./routes/_app.tsx": $_app,
|
||||
"./routes/_middleware.ts": $_middleware,
|
||||
"./routes/docs/[...slug].tsx": $docs_slug_,
|
||||
"./routes/docs/_middleware.ts": $docs_middleware,
|
||||
"./routes/docs/index.tsx": $docs_index,
|
||||
"./routes/index.tsx": $index,
|
||||
"./routes/raw.ts": $raw,
|
||||
"./routes/recipes/_layout.tsx": $recipes_layout,
|
||||
"./routes/recipes/lemon-honey-tea.tsx": $recipes_lemon_honey_tea,
|
||||
"./routes/recipes/lemonade.tsx": $recipes_lemonade,
|
||||
"./routes/recipes/lemondrop.tsx": $recipes_lemondrop,
|
||||
"./routes/showcase.tsx": $showcase,
|
||||
"./routes/thanks.tsx": $thanks,
|
||||
"./routes/update.tsx": $update,
|
||||
},
|
||||
islands: {
|
||||
"./islands/CopyArea.tsx": $CopyArea,
|
||||
"./islands/Counter.tsx": $Counter,
|
||||
"./islands/FormSubmitDemo.tsx": $FormSubmitDemo,
|
||||
"./islands/LemonBottom.tsx": $LemonBottom,
|
||||
"./islands/LemonDrop.tsx": $LemonDrop,
|
||||
"./islands/LemonTop.tsx": $LemonTop,
|
||||
"./islands/SearchButton.tsx": $SearchButton,
|
||||
"./islands/TableOfContents.tsx": $TableOfContents,
|
||||
"./islands/VersionSelect.tsx": $VersionSelect,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
} satisfies Manifest;
|
||||
|
||||
export default manifest;
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ComponentChildren } from "preact";
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
import { IS_BROWSER } from "@fresh/core/runtime";
|
||||
import * as Icons from "../components/Icons.tsx";
|
||||
import { useSignal } from "@preact/signals";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useSignal } from "@preact/signals";
|
||||
import * as Icons from "../components/Icons.tsx";
|
||||
import { JSX } from "preact";
|
||||
import type { JSX } from "preact";
|
||||
|
||||
interface CounterProps {
|
||||
start: number;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import docsearch from "https://esm.sh/@docsearch/js@3.5.2?target=es2020";
|
||||
|
||||
@@ -25,19 +24,11 @@ export default function SearchButton(
|
||||
}
|
||||
}, [ref.current]);
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/docsearch.css"
|
||||
/>
|
||||
</Head>
|
||||
<div
|
||||
title="Search Button"
|
||||
class={"h-9 mb-6 " + (props.class ?? "")}
|
||||
ref={ref}
|
||||
>
|
||||
</div>
|
||||
</>
|
||||
<div
|
||||
title="Search Button"
|
||||
class={"h-9 mb-6 " + (props.class ?? "")}
|
||||
ref={ref}
|
||||
>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import { MarkdownHeading } from "../utils/markdown.ts";
|
||||
import type { MarkdownHeading } from "../utils/markdown.ts";
|
||||
|
||||
export interface TableOfContentsProps {
|
||||
headings: MarkdownHeading[];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022-2023 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
import { type VersionLink } from "../routes/docs/[...slug].tsx";
|
||||
import { IS_BROWSER } from "@fresh/core/runtime";
|
||||
import type { VersionLink } from "../routes/docs/[...slug].tsx";
|
||||
|
||||
export default function VersionSelect(
|
||||
{ versions, selectedVersion }: {
|
||||
|
||||
+10
-9
@@ -1,12 +1,13 @@
|
||||
/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
import { App, fsRoutes, staticFiles } from "@fresh/core";
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
export const app = new App({ root: import.meta.url })
|
||||
.use(staticFiles());
|
||||
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import config from "./fresh.config.ts";
|
||||
await fsRoutes(app, {
|
||||
loadIsland: (path) => import(`./islands/${path}`),
|
||||
loadRoute: (path) => import(`./routes/${path}`),
|
||||
});
|
||||
|
||||
await start(manifest, config);
|
||||
if (import.meta.main) {
|
||||
await app.listen();
|
||||
}
|
||||
|
||||
+66
-56
@@ -1,71 +1,81 @@
|
||||
import { assertArrayIncludes, assertEquals } from "$std/assert/mod.ts";
|
||||
import { withPageName } from "../tests/test_utils.ts";
|
||||
import { dirname, join } from "$std/path/mod.ts";
|
||||
import VERSIONS from "../versions.json" with { type: "json" };
|
||||
import { createHandler } from "../server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import config from "./fresh.config.ts";
|
||||
import { app } from "./main.ts";
|
||||
import { buildProd, withBrowserApp } from "../tests/test_utils.tsx";
|
||||
import { expect } from "@std/expect";
|
||||
|
||||
const dir = dirname(import.meta.url);
|
||||
const handler = await createHandler(manifest, config);
|
||||
const handler = await app.handler();
|
||||
|
||||
Deno.test("CORS should not set on GET /fresh-badge.svg", async () => {
|
||||
const req = new Request("http://localhost/fresh-badge.svg");
|
||||
await buildProd(app);
|
||||
const resp = await handler(req);
|
||||
await resp?.body?.cancel();
|
||||
|
||||
assertEquals(resp.headers.get("cross-origin-resource-policy"), null);
|
||||
expect(resp.headers.get("cross-origin-resource-policy")).toEqual(null);
|
||||
});
|
||||
|
||||
Deno.test("shows version selector", async () => {
|
||||
await withPageName(join(dir, "./main.ts"), async (page, address) => {
|
||||
await page.goto(`${address}/docs`);
|
||||
await page.waitForSelector("#version");
|
||||
Deno.test({
|
||||
name: "shows version selector",
|
||||
fn: async () => {
|
||||
await withBrowserApp(app, async (page, address) => {
|
||||
await page.goto(`${address}/docs`);
|
||||
await page.waitForSelector("#version");
|
||||
|
||||
// Check that we redirected to the first page
|
||||
assertEquals(page.url(), `${address}/docs/introduction`);
|
||||
// Check that we redirected to the first page
|
||||
await page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.pathname === "/docs/introduction";
|
||||
});
|
||||
|
||||
// Wait for version selector to be enabled
|
||||
await page.waitForSelector("#version:not([disabled])");
|
||||
// Wait for version selector to be enabled
|
||||
await page.waitForSelector("#version:not([disabled])");
|
||||
|
||||
const options = await page.$eval("#version", (el: HTMLSelectElement) => {
|
||||
return Array.from(el.options).map((option) => ({
|
||||
value: option.value,
|
||||
label: option.textContent,
|
||||
}));
|
||||
const options = await page
|
||||
.locator<HTMLSelectElement>("#version")
|
||||
.evaluate((el) => {
|
||||
return Array.from(el.options).map((option) => ({
|
||||
value: option.value,
|
||||
label: option.textContent,
|
||||
}));
|
||||
});
|
||||
|
||||
expect(options).toEqual([
|
||||
{
|
||||
value: "canary",
|
||||
label: "canary",
|
||||
},
|
||||
{
|
||||
value: "latest",
|
||||
label: VERSIONS[0],
|
||||
},
|
||||
]);
|
||||
|
||||
const selectValue = await page
|
||||
.locator<HTMLSelectElement>("#version")
|
||||
.evaluate((el) => el.value);
|
||||
expect(selectValue).toEqual("latest");
|
||||
|
||||
// Go to canary page
|
||||
await page.evaluate(() => {
|
||||
const el = document.querySelector("#version") as HTMLSelectElement;
|
||||
el.value = "canary";
|
||||
el.dispatchEvent(new Event("change"));
|
||||
});
|
||||
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
|
||||
await page.waitForSelector("#version:not([disabled])");
|
||||
const selectValue2 = await page
|
||||
.locator<HTMLSelectElement>("#version")
|
||||
.evaluate((el) => el.value);
|
||||
expect(selectValue2).toEqual("canary");
|
||||
|
||||
await page.waitForFunction(() => {
|
||||
const url = new URL(window.location.href);
|
||||
return url.pathname === "/docs/canary/introduction";
|
||||
});
|
||||
});
|
||||
|
||||
assertEquals(options.length, 2);
|
||||
assertArrayIncludes(options, [
|
||||
{
|
||||
value: "canary",
|
||||
label: "canary",
|
||||
},
|
||||
{
|
||||
value: "latest",
|
||||
label: VERSIONS[0],
|
||||
},
|
||||
]);
|
||||
|
||||
const selectValue = await page.$eval(
|
||||
"#version",
|
||||
(el: HTMLSelectElement) => el.value,
|
||||
);
|
||||
assertEquals(selectValue, "latest");
|
||||
|
||||
// Go to canary page
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.select("#version", "canary"),
|
||||
]);
|
||||
|
||||
await page.waitForSelector("#version:not([disabled])");
|
||||
const selectValue2 = await page.$eval(
|
||||
"#version",
|
||||
(el: HTMLSelectElement) => el.value,
|
||||
);
|
||||
assertEquals(selectValue2, "canary");
|
||||
|
||||
assertEquals(page.url(), `${address}/docs/canary/introduction`);
|
||||
});
|
||||
},
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
+33
-6
@@ -1,24 +1,51 @@
|
||||
import { PageProps } from "$fresh/server.ts";
|
||||
import { asset } from "@fresh/core/runtime";
|
||||
import { df } from "../utils/state.ts";
|
||||
|
||||
export default function App({ Component }: PageProps) {
|
||||
export default df.definePage(function App({ Component, state, url }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>My Fresh app</title>
|
||||
{state.title ? <title>{state.title}</title> : null}
|
||||
{state.description
|
||||
? <meta name="description" content={state.description} />
|
||||
: null}
|
||||
{state.title
|
||||
? <meta property="og:title" content={state.title} />
|
||||
: null}
|
||||
{state.description
|
||||
? <meta property="og:description" content={state.description} />
|
||||
: null}
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content={url.href} />
|
||||
{state.ogImage
|
||||
? <meta property="og:image" content={state.ogImage} />
|
||||
: null}
|
||||
{state.noIndex ? <meta name="robots" content="noindex" /> : null}
|
||||
<link
|
||||
rel="preload"
|
||||
href="/fonts/FixelVariable.woff2"
|
||||
href={asset("/fonts/FixelVariable.woff2")}
|
||||
as="font"
|
||||
type="font/woff2"
|
||||
crossorigin="true"
|
||||
/>
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
<link rel="stylesheet" href={asset("/styles.css")} />
|
||||
{url.pathname === "/"
|
||||
? <link rel="stylesheet" href={asset("/prism.css")} />
|
||||
: null}
|
||||
{url.pathname.startsWith("/docs/")
|
||||
? (
|
||||
<>
|
||||
<link rel="stylesheet" href={asset("/docsearch.css")} />
|
||||
<link rel="stylesheet" href={asset("/markdown.css")} />
|
||||
</>
|
||||
)
|
||||
: null}
|
||||
</head>
|
||||
<body>
|
||||
<Component />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type FreshContext } from "$fresh/server.ts";
|
||||
import type { FreshContext } from "@fresh/core";
|
||||
import type { Event } from "$ga4";
|
||||
import { GA4Report, isDocument, isServerError } from "$ga4";
|
||||
|
||||
@@ -62,7 +62,14 @@ function ga4(
|
||||
// Create basic report.
|
||||
const measurementId = GA4_MEASUREMENT_ID;
|
||||
// @ts-ignore GA4Report doesn't even use the localAddress parameter
|
||||
const report = new GA4Report({ measurementId, request, response, conn });
|
||||
const report = new GA4Report({
|
||||
measurementId,
|
||||
request,
|
||||
response,
|
||||
// Doesn't use localAddr
|
||||
// deno-lint-ignore no-explicit-any
|
||||
conn: conn.info as any,
|
||||
});
|
||||
|
||||
// Override the default (page_view) event.
|
||||
report.event = event;
|
||||
@@ -74,12 +81,11 @@ function ga4(
|
||||
|
||||
await report.send();
|
||||
}).catch((err) => {
|
||||
console.error(`Internal error: ${err}`);
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
export async function handler(
|
||||
req: Request,
|
||||
ctx: FreshContext,
|
||||
): Promise<Response> {
|
||||
let err;
|
||||
@@ -98,7 +104,7 @@ export async function handler(
|
||||
throw e;
|
||||
} finally {
|
||||
ga4(
|
||||
req,
|
||||
ctx.req,
|
||||
ctx,
|
||||
res!,
|
||||
start,
|
||||
|
||||
+109
-122
@@ -1,5 +1,5 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { asset, Head, Partial } from "$fresh/runtime.ts";
|
||||
import { type Handlers, HttpError, type PageProps } from "@fresh/core";
|
||||
import { asset, Partial } from "@fresh/core/runtime";
|
||||
import { SidebarCategory } from "../../components/DocsSidebar.tsx";
|
||||
import Footer from "../../components/Footer.tsx";
|
||||
import Header from "../../components/Header.tsx";
|
||||
@@ -8,13 +8,13 @@ import {
|
||||
getFirstPageUrl,
|
||||
LATEST_VERSION,
|
||||
TABLE_OF_CONTENTS,
|
||||
TableOfContentsEntry,
|
||||
type TableOfContentsEntry,
|
||||
} from "../../data/docs.ts";
|
||||
import { frontMatter, renderMarkdown } from "../../utils/markdown.ts";
|
||||
import toc from "../../../docs/toc.ts";
|
||||
import { TableOfContents } from "../../islands/TableOfContents.tsx";
|
||||
import SearchButton from "$fresh/www/islands/SearchButton.tsx";
|
||||
import VersionSelect from "$fresh/www/islands/VersionSelect.tsx";
|
||||
import SearchButton from "../../islands/SearchButton.tsx";
|
||||
import VersionSelect from "../../islands/VersionSelect.tsx";
|
||||
|
||||
interface Data {
|
||||
page: Page;
|
||||
@@ -44,7 +44,7 @@ interface Page extends TableOfContentsEntry {
|
||||
const pattern = new URLPattern({ pathname: "/:version/:page*" });
|
||||
|
||||
export const handler: Handlers<Data> = {
|
||||
async GET(_req, ctx) {
|
||||
async GET(ctx) {
|
||||
const slug = ctx.params.slug;
|
||||
|
||||
// Check if the slug is the index page of a version tag
|
||||
@@ -58,12 +58,12 @@ export const handler: Handlers<Data> = {
|
||||
|
||||
const match = pattern.exec("https://localhost/" + slug);
|
||||
if (!match) {
|
||||
return ctx.renderNotFound();
|
||||
throw new HttpError(404);
|
||||
}
|
||||
|
||||
let { version, page = "" } = match.pathname.groups;
|
||||
if (!version) {
|
||||
return ctx.renderNotFound();
|
||||
throw new HttpError(404);
|
||||
}
|
||||
|
||||
// Latest version doesn't show up in the url
|
||||
@@ -76,7 +76,7 @@ export const handler: Handlers<Data> = {
|
||||
const currentToc = TABLE_OF_CONTENTS[version];
|
||||
const entry = currentToc[page];
|
||||
if (!entry) {
|
||||
return ctx.renderNotFound();
|
||||
throw new HttpError(404);
|
||||
}
|
||||
|
||||
// Build up the link map for the version selector.
|
||||
@@ -122,137 +122,124 @@ export const handler: Handlers<Data> = {
|
||||
const fileContent = await Deno.readTextFile(url);
|
||||
const { body, attrs } = frontMatter<Record<string, unknown>>(fileContent);
|
||||
|
||||
return ctx.render({
|
||||
page: {
|
||||
...entry,
|
||||
markdown: body,
|
||||
data: attrs ?? {},
|
||||
versionLinks,
|
||||
version,
|
||||
prevNav,
|
||||
nextNav,
|
||||
ctx.state.title = `${entry.title ?? "Not Found"} | Fresh docs`;
|
||||
ctx.state.description = attrs?.description
|
||||
? String(attrs.description)
|
||||
: "Fresh Document";
|
||||
ctx.state.ogImage = new URL(asset("/og-image.webp"), ctx.url).href;
|
||||
|
||||
return {
|
||||
data: {
|
||||
page: {
|
||||
...entry,
|
||||
markdown: body,
|
||||
data: attrs ?? {},
|
||||
versionLinks,
|
||||
version,
|
||||
prevNav,
|
||||
nextNav,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default function DocsPage(props: PageProps<Data>) {
|
||||
const { page } = props.data;
|
||||
const ogImageUrl = new URL(asset("/og-image.webp"), props.url).href;
|
||||
const title = `${page?.title ?? "Not Found"} | Fresh docs`;
|
||||
let description = "Fresh Document";
|
||||
|
||||
if (page.data.description) {
|
||||
description = String(page.data.description);
|
||||
}
|
||||
|
||||
const { html, headings } = renderMarkdown(page.markdown);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href={asset("/markdown.css")} />
|
||||
<meta name="description" content={description} />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={description} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content={props.url.href} />
|
||||
<meta property="og:image" content={ogImageUrl} />
|
||||
<meta name="view-transition" content="same-origin" />
|
||||
</Head>
|
||||
<div class="flex flex-col min-h-screen mx-auto max-w-screen-2xl">
|
||||
<Header title="docs" active="/docs" />
|
||||
<div f-client-nav={true}>
|
||||
<MobileSidebar page={page} />
|
||||
<div class="flex mx-auto max-w-screen-2xl px-0 md:px-4 md:py-0 justify-start bg-gray-100">
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-3 lg:hidden flex items-center hover:bg-gray-100 rounded gap-2 cursor-pointer"
|
||||
<div class="flex flex-col min-h-screen mx-auto max-w-screen-2xl">
|
||||
<Header title="docs" active="/docs" />
|
||||
<div f-client-nav={true}>
|
||||
<MobileSidebar page={page} />
|
||||
<div class="flex mx-auto max-w-screen-2xl px-0 md:px-4 md:py-0 justify-start bg-gray-100">
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-3 lg:hidden flex items-center hover:bg-gray-100 rounded gap-2 cursor-pointer"
|
||||
>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M4 6h16M4 12h16M4 18h7"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M4 6h16M4 12h16M4 18h7"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
<div>Table of Contents</div>
|
||||
</label>
|
||||
</div>
|
||||
<nav class="flex-shrink-0 hidden lg:block lg:px-4 bg-white">
|
||||
<div class="fixed top-24 w-[17rem] flex overflow-hidden">
|
||||
<div class="flex-1 h-[calc(100vh_-_6rem)] overflow-y-auto pb-8">
|
||||
<SearchButton class="mr-4 sm:mr-0" />
|
||||
<div class="mb-4">
|
||||
<VersionSelect
|
||||
selectedVersion={page.version}
|
||||
versions={page.versionLinks}
|
||||
/>
|
||||
</div>
|
||||
<ul class="list-inside font-semibold nested ml-2.5">
|
||||
{CATEGORIES[page.version].map((category) => (
|
||||
<SidebarCategory key={category.href} category={category} />
|
||||
))}
|
||||
</ul>
|
||||
</path>
|
||||
</svg>
|
||||
<div>Table of Contents</div>
|
||||
</label>
|
||||
</div>
|
||||
<nav class="flex-shrink-0 hidden lg:block lg:px-4 bg-white">
|
||||
<div class="fixed top-24 w-[17rem] flex overflow-hidden">
|
||||
<div class="flex-1 h-[calc(100vh_-_6rem)] overflow-y-auto pb-8">
|
||||
<SearchButton class="mr-4 sm:mr-0" />
|
||||
<div class="mb-4">
|
||||
<VersionSelect
|
||||
selectedVersion={page.version}
|
||||
versions={page.versionLinks}
|
||||
/>
|
||||
</div>
|
||||
<ul class="list-inside font-semibold nested ml-2.5">
|
||||
{CATEGORIES[page.version].map((category) => (
|
||||
<SidebarCategory key={category.href} category={category} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<Partial name="docs-main">
|
||||
<div class="w-full min-w-0">
|
||||
<main class="lg:ml-[18rem] mt-4 min-w-0 mx-auto">
|
||||
<div class="flex gap-6 md:gap-8 xl:gap-[8%] flex-col xl:flex-row md:mx-8 lg:mx-16 2xl:mx-0 lg:justify-end">
|
||||
<TableOfContents headings={headings} />
|
||||
</div>
|
||||
</nav>
|
||||
<Partial name="docs-main">
|
||||
<div class="w-full min-w-0">
|
||||
<main class="lg:ml-[18rem] mt-4 min-w-0 mx-auto">
|
||||
<div class="flex gap-6 md:gap-8 xl:gap-[8%] flex-col xl:flex-row md:mx-8 lg:mx-16 2xl:mx-0 lg:justify-end">
|
||||
<TableOfContents headings={headings} />
|
||||
|
||||
<div class="lg:order-1 min-w-0 max-w-3xl w-full">
|
||||
<h1 class="text-4xl text-gray-900 tracking-tight font-bold md:mt-0 px-4 md:px-0 mb-4">
|
||||
{page.title}
|
||||
</h1>
|
||||
<div
|
||||
class="markdown-body mb-8"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
<div class="lg:order-1 min-w-0 max-w-3xl w-full">
|
||||
<h1 class="text-4xl text-gray-900 tracking-tight font-bold md:mt-0 px-4 md:px-0 mb-4">
|
||||
{page.title}
|
||||
</h1>
|
||||
<div
|
||||
class="markdown-body mb-8"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
|
||||
<div class="mb-8">
|
||||
<ForwardBackButtons
|
||||
slug={page.slug}
|
||||
version={page.version}
|
||||
prev={page.prevNav}
|
||||
next={page.nextNav}
|
||||
/>
|
||||
|
||||
<div class="mb-8">
|
||||
<ForwardBackButtons
|
||||
slug={page.slug}
|
||||
version={page.version}
|
||||
prev={page.prevNav}
|
||||
next={page.nextNav}
|
||||
/>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="px-4 md:px-0 flex justify-between my-6">
|
||||
<a
|
||||
href={`https://github.com/denoland/fresh/edit/main/${page.file}`}
|
||||
class="text-green-600 underline flex items-center"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<svg class="w-4 h-4 inline-block mr-1">
|
||||
<use href="/icons.svg#external" />
|
||||
</svg>
|
||||
Edit this page on GitHub
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="px-4 md:px-0 flex justify-between my-6">
|
||||
<a
|
||||
href={`https://github.com/denoland/fresh/edit/main/${page.file}`}
|
||||
class="text-green-600 underline flex items-center"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<svg class="w-4 h-4 inline-block mr-1">
|
||||
<use href="/icons.svg#external" />
|
||||
</svg>
|
||||
Edit this page on GitHub
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="xl:ml-[3.75rem]">
|
||||
<Footer />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</Partial>
|
||||
</div>
|
||||
</div>
|
||||
<div class="xl:ml-[3.75rem]">
|
||||
<Footer />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</Partial>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FreshContext } from "$fresh/server.ts";
|
||||
import type { FreshContext } from "@fresh/core";
|
||||
|
||||
const REDIRECTS: Record<string, string> = {
|
||||
"/docs/getting-started/fetching-data":
|
||||
@@ -6,7 +6,6 @@ const REDIRECTS: Record<string, string> = {
|
||||
};
|
||||
|
||||
export async function handler(
|
||||
_req: Request,
|
||||
ctx: FreshContext,
|
||||
) {
|
||||
// Redirect from old doc URLs to new ones
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MultiHandler } from "$fresh/server.ts";
|
||||
import type { Handler } from "@fresh/core";
|
||||
|
||||
export const handler: MultiHandler<void> = {
|
||||
GET(_req, ctx) {
|
||||
export const handler: Handler<void> = {
|
||||
GET(ctx) {
|
||||
const slug = ctx.params.slug;
|
||||
|
||||
if (slug === "concepts/architechture") {
|
||||
|
||||
+43
-55
@@ -1,20 +1,22 @@
|
||||
import { asset, Head } from "$fresh/runtime.ts";
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import VERSIONS from "$fresh/versions.json" with { type: "json" };
|
||||
import Footer from "$fresh/www/components/Footer.tsx";
|
||||
import Header from "$fresh/www/components/Header.tsx";
|
||||
import { CTA } from "$fresh/www/components/homepage/CTA.tsx";
|
||||
import { Hero } from "$fresh/www/components/homepage/Hero.tsx";
|
||||
import { IslandsSection } from "$fresh/www/components/homepage/IslandsSection.tsx";
|
||||
import { PartialsSection } from "$fresh/www/components/homepage/PartialsSection.tsx";
|
||||
import { RenderingSection } from "$fresh/www/components/homepage/RenderingSection.tsx";
|
||||
import { asset } from "@fresh/core/runtime";
|
||||
import type { Handlers, PageProps } from "@fresh/core";
|
||||
import VERSIONS from "../../versions.json" with { type: "json" };
|
||||
import Footer from "../components/Footer.tsx";
|
||||
import Header from "../components/Header.tsx";
|
||||
import { CTA } from "../components/homepage/CTA.tsx";
|
||||
import { Hero } from "../components/homepage/Hero.tsx";
|
||||
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 "$fresh/www/components/homepage/Simple.tsx";
|
||||
import { SocialProof } from "$fresh/www/components/homepage/SocialProof.tsx";
|
||||
import { DenoSection } from "$fresh/www/components/homepage/DenoSection.tsx";
|
||||
import { Simple } from "../components/homepage/Simple.tsx";
|
||||
import { SocialProof } from "../components/homepage/SocialProof.tsx";
|
||||
import { DenoSection } from "../components/homepage/DenoSection.tsx";
|
||||
import { df } from "../utils/state.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req, ctx) {
|
||||
export const handler = df.defineHandlers({
|
||||
GET(ctx) {
|
||||
const { req } = ctx;
|
||||
const accept = req.headers.get("accept");
|
||||
const userAgent = req.headers.get("user-agent");
|
||||
if (userAgent?.includes("Deno/") && !accept?.includes("text/html")) {
|
||||
@@ -24,11 +26,16 @@ export const handler: Handlers = {
|
||||
status: 307,
|
||||
});
|
||||
}
|
||||
return ctx.render();
|
||||
|
||||
ctx.state.title =
|
||||
"Fresh - The simple, approachable, productive web framework.";
|
||||
ctx.state.description =
|
||||
"Fresh features just-in-time edge rendering, island based interactivity, and zero-configuration TypeScript support. Fast to write; fast to run.";
|
||||
ctx.state.ogImage = new URL(asset("/og-image.webp"), ctx.url).href;
|
||||
},
|
||||
async POST(req) {
|
||||
async POST(ctx) {
|
||||
const headers = new Headers();
|
||||
const form = await req.formData();
|
||||
const form = await ctx.req.formData();
|
||||
const treat = form.get("treat");
|
||||
headers.set("location", `/thanks?vote=${treat}`);
|
||||
return new Response(null, {
|
||||
@@ -36,49 +43,30 @@ export const handler: Handlers = {
|
||||
headers,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const TITLE = "Fresh - The simple, approachable, productive web framework.";
|
||||
const DESCRIPTION =
|
||||
"Fresh features just-in-time edge rendering, island based interactivity, and zero-configuration TypeScript support. Fast to write; fast to run.";
|
||||
});
|
||||
|
||||
export default function MainPage(props: PageProps) {
|
||||
const ogImageUrl = new URL(asset("/og-image.webp"), props.url).href;
|
||||
const origin = `${props.url.protocol}//${props.url.host}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{TITLE}</title>
|
||||
<meta name="description" content={DESCRIPTION} />
|
||||
<meta property="og:title" content={TITLE} />
|
||||
<meta property="og:description" content={DESCRIPTION} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content={props.url.href} />
|
||||
<meta property="og:image" content={ogImageUrl} />
|
||||
<meta name="view-transition" content="same-origin" />
|
||||
<link rel="stylesheet" href="/prism.css" />
|
||||
</Head>
|
||||
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<div class="bg-transparent flex flex-col relative z-10">
|
||||
<HelloBar />
|
||||
<Header title="" active="/" />
|
||||
</div>
|
||||
<div class="flex flex-col -mt-20 relative">
|
||||
<Hero origin={origin} />
|
||||
<Simple />
|
||||
<RenderingSection />
|
||||
<IslandsSection />
|
||||
<FormsSection />
|
||||
<PartialsSection />
|
||||
<SocialProof />
|
||||
<DenoSection />
|
||||
<CTA />
|
||||
</div>
|
||||
<Footer class="!mt-0" />
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<div class="bg-transparent flex flex-col relative z-10">
|
||||
<HelloBar />
|
||||
<Header title="" active="/" />
|
||||
</div>
|
||||
</>
|
||||
<div class="flex flex-col -mt-20 relative">
|
||||
<Hero origin={origin} />
|
||||
<Simple />
|
||||
<RenderingSection />
|
||||
<IslandsSection />
|
||||
<FormsSection />
|
||||
<PartialsSection />
|
||||
<SocialProof />
|
||||
<DenoSection />
|
||||
<CTA />
|
||||
</div>
|
||||
<Footer class="!mt-0" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -1,5 +1,4 @@
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import type { Handlers, RouteConfig } from "@fresh/core";
|
||||
import { format, parse } from "$std/semver/mod.ts";
|
||||
import VERSIONS from "../../versions.json" with { type: "json" };
|
||||
import { extname } from "$std/path/mod.ts";
|
||||
@@ -17,8 +16,8 @@ const contentTypes = new Map([
|
||||
]);
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, ctx) {
|
||||
const accept = req.headers.get("Accept");
|
||||
async GET(ctx) {
|
||||
const accept = ctx.req.headers.get("Accept");
|
||||
const isHTML = accept?.includes("text/html");
|
||||
const { version, path } = ctx.params;
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { PageProps } from "$fresh/server.ts";
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import Header from "$fresh/www/components/Header.tsx";
|
||||
import type { PageProps } from "@fresh/core";
|
||||
import Header from "../../components/Header.tsx";
|
||||
|
||||
export default function Layout({ Component, state }: PageProps) {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<meta name="robots" content="noindex" />
|
||||
</Head>
|
||||
<Header active="" title="" />
|
||||
|
||||
<div class="w-full max-w-screen-xl px-4">
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { df } from "../../utils/state.ts";
|
||||
|
||||
export const handler = df.defineMiddleware((ctx) => {
|
||||
ctx.state.noIndex = true;
|
||||
return ctx.next();
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "@fresh/core/runtime";
|
||||
import type { RouteConfig } from "@fresh/core";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Head, Partial } from "$fresh/runtime.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "@fresh/core/runtime";
|
||||
import type { RouteConfig } from "@fresh/core";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { Partial } from "@fresh/core/runtime";
|
||||
import type { RouteConfig } from "@fresh/core";
|
||||
|
||||
export const config: RouteConfig = {
|
||||
skipAppWrapper: true,
|
||||
|
||||
+12
-14
@@ -1,27 +1,25 @@
|
||||
import { asset, Head } from "$fresh/runtime.ts";
|
||||
import { PageProps } from "$fresh/server.ts";
|
||||
import Projects, { Project } from "../components/Projects.tsx";
|
||||
import { asset } from "@fresh/core/runtime";
|
||||
import type { PageProps } from "@fresh/core";
|
||||
import Projects, { type Project } from "../components/Projects.tsx";
|
||||
import Header from "../components/Header.tsx";
|
||||
import Footer from "../components/Footer.tsx";
|
||||
import projects from "../data/showcase.json" with { type: "json" };
|
||||
import { df } from "../utils/state.ts";
|
||||
|
||||
const TITLE = "Showcase | Fresh";
|
||||
const DESCRIPTION = "Selection of projects that have been built with Fresh.";
|
||||
|
||||
export const handler = df.defineHandlers({
|
||||
GET(ctx) {
|
||||
ctx.state.title = TITLE;
|
||||
ctx.state.description = DESCRIPTION;
|
||||
ctx.state.ogImage = new URL(asset("/og-image.webp"), ctx.url).href;
|
||||
},
|
||||
});
|
||||
|
||||
export default function ShowcasePage(props: PageProps) {
|
||||
const ogImageUrl = new URL(asset("/og-image.webp"), props.url).href;
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{TITLE}</title>
|
||||
<meta name="description" content={DESCRIPTION} />
|
||||
<meta property="og:title" content={TITLE} />
|
||||
<meta property="og:description" content={DESCRIPTION} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content={props.url.href} />
|
||||
<meta property="og:image" content={ogImageUrl} />
|
||||
<meta name="view-transition" content="same-origin" />
|
||||
</Head>
|
||||
<Header title="showcase" active="/showcase" />
|
||||
|
||||
<div class="flex flex-col min-h-screen">
|
||||
|
||||
+11
-15
@@ -1,26 +1,22 @@
|
||||
import { PageSection } from "$fresh/www/components/PageSection.tsx";
|
||||
import { DemoBox } from "$fresh/www/components/homepage/DemoBox.tsx";
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { PageSection } from "../components/PageSection.tsx";
|
||||
import { DemoBox } from "../components/homepage/DemoBox.tsx";
|
||||
import { df } from "../utils/state.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req, ctx) {
|
||||
const url = new URL(req.url);
|
||||
export const handler = df.defineHandlers({
|
||||
GET(ctx) {
|
||||
const url = new URL(ctx.req.url);
|
||||
const search = new URLSearchParams(url.search);
|
||||
const vote = search.get("vote");
|
||||
return ctx.render({ vote });
|
||||
return { data: { vote } };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export default function ThanksForSubscribing(
|
||||
props: PageProps & { vote?: string },
|
||||
export default df.definePage<typeof handler>(function ThanksForSubscribing(
|
||||
props,
|
||||
) {
|
||||
const vote = props?.data?.vote ? props.data.vote.replaceAll(/-/g, " ") : null;
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<meta name="robots" content="noindex" />
|
||||
</Head>
|
||||
<PageSection>
|
||||
<DemoBox>
|
||||
<div class="space-y-2">
|
||||
@@ -67,4 +63,4 @@ export default function ThanksForSubscribing(
|
||||
</PageSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import type { Handlers } from "@fresh/core";
|
||||
import VERSIONS from "../../versions.json" with { type: "json" };
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req) {
|
||||
GET({ req }) {
|
||||
const accept = req.headers.get("accept");
|
||||
let path = "/docs/concepts/updating";
|
||||
if (accept && !accept.includes("text/html")) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Config } from "tailwindcss";
|
||||
import type { Config } from "tailwindcss";
|
||||
import plugin from "tailwindcss/plugin";
|
||||
|
||||
export default {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { createHelpers } from "@fresh/core";
|
||||
|
||||
export interface State {
|
||||
title?: string;
|
||||
description?: string;
|
||||
ogImage?: string;
|
||||
noIndex?: boolean;
|
||||
}
|
||||
|
||||
export const df = createHelpers<State>();
|
||||
Reference in New Issue
Block a user