+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")) {
|
||||
|
||||
Reference in New Issue
Block a user