docs: new website (#66)

This commit is contained in:
Luca Casonato
2021-10-04 11:12:12 +02:00
committed by GitHub
parent 044da54513
commit 4a6b57de89
29 changed files with 311 additions and 163 deletions
+20
View File
@@ -0,0 +1,20 @@
# fresh website
This is the fresh website source. The fresh website contains:
- a homepage
- a documentation page
### Usage
Start the project:
```
deno run -A --watch main.ts
```
After adding, removing, or moving a page in the `pages` directory, run:
```
fresh routes
```
+13
View File
@@ -0,0 +1,13 @@
/** @jsx h */
import { h, tw } from "../deps.ts";
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
return (
<button
{...props}
class={tw
`p-3 border border-transparent rounded-full text-white bg-indigo(600 hover:700) focus:(outline-none ring(2 offset-2 indigo-500)) disabled:(bg-indigo-200 cursor-default)`}
/>
);
}
+43
View File
@@ -0,0 +1,43 @@
/** @jsx h */
import { h, tw } from "../deps.ts";
export function IconMinus() {
return (
<svg
class={tw`h-6 w-6`}
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M20 12H4"
/>
</svg>
);
}
export function IconPlus() {
return (
<svg
class={tw`h-6 w-6`}
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/>
</svg>
);
}
+13
View File
@@ -0,0 +1,13 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
export * from "../runtime.ts";
import { IS_BROWSER } from "../runtime.ts";
import { setup, tw } from "https://esm.sh/twind";
export { setup, tw };
if (IS_BROWSER) {
setup({});
}
+4
View File
@@ -0,0 +1,4 @@
import { start } from "../server.ts";
import routes from "./routes.gen.ts";
await start(routes);
+18
View File
@@ -0,0 +1,18 @@
// This module adds twind support.
import { virtualSheet } from "https://esm.sh/twind/sheets";
import { setup } from "../deps.ts";
import { RenderContext, RenderFn } from "../server_deps.ts";
const sheet = virtualSheet();
sheet.reset();
setup({ sheet });
export function render(ctx: RenderContext, render: RenderFn) {
const snapshot = ctx.state.get("twindSnapshot") as unknown[] | null;
sheet.reset(snapshot || undefined);
render();
ctx.styles.splice(0, ctx.styles.length, ...sheet.target);
const newSnapshot = sheet.reset();
ctx.state.set("twindSnapshot", newSnapshot);
}
+155
View File
@@ -0,0 +1,155 @@
/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, tw } from "../deps.ts";
export default function MainPage() {
return (
<>
<Hero />
<NavigationBar active="/" />
<Intro />
<GettingStarted />
</>
);
}
function Hero() {
const container = tw`w-full h-64 flex justify-center items-center flex-col`;
const title = tw
`text(4xl sm:5xl lg:6xl gray-900) sm:tracking-tight font-extrabold`;
const subtitle = tw`mt-4 text(2xl gray-600)`;
return (
<section class={container}>
<h1 class={title}>
fresh
</h1>
<h3 class={subtitle}>
The next-gen web framework.
</h3>
</section>
);
}
function NavigationBar(props: { active: string }) {
const items = [
{
name: "Home",
href: "/",
},
{
name: "Docs",
href: "/docs",
},
];
return (
<nav class={tw`bg(gray-50) py-2 border(t-2 b-2 gray-100)`}>
<ul class={tw`flex justify-center gap-8 mx-4`}>
{items.map((item) => (
<li>
<a
href={item.href}
class={tw`text-gray-600 hover:underline ${
props.active == item.href ? "font-bold" : ""
}`}
>
{item.name}
</a>
</li>
))}
</ul>
</nav>
);
}
function Intro() {
return (
<section class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8)`}>
<p class={tw`my-4 text-gray-600`}>
Fresh is a next generation web framework, built for speed, reliability,
and simplicity. Some stand out features:
</p>
<ul class={tw`my-4 text-gray-600 list-disc list-inside pl-4`}>
<li>
<b>Just-in-time rendering</b> on the edge.
</li>
<li>
<b>Selective client hydration</b> for maximum interactivity.
</li>
<li>
<b>Zero runtime overhead</b>: no JS is shipped to the client by
default.
</li>
<li>
<b>No build step</b>.
</li>
<li>
<b>No configuration</b> necessary.
</li>
<li>
<b>TypeScript support</b> out of the box.
</li>
</ul>
<p class={tw`my-4 text-gray-600`}>
Fresh embraces the tried and true design of server side rendering and
processing.
</p>
</section>
);
}
function GettingStarted() {
return (
<section class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8)`}>
<h3 id="getting-started" class={tw`text(xl gray-600) font-bold`}>
<a href="#getting-started" class={tw`hover:underline`}>
Getting started
</a>
</h3>
<p class={tw`my-4 text-gray-600`}>
To get started, make sure you have the{" "}
<a href="https://deno.land" class={tw`text-blue-500 hover:underline`}>
Deno CLI
</a>{" "}
installed.
</p>
<p class={tw`my-4 text-gray-600`}>
Then, run the following command to install the `fresh` CLI:
</p>
<pre class={tw`overflow-x-auto py-2 px-4 bg(gray-100)`}>
deno install -A -f --no-check -n fresh
https://raw.githubusercontent.com/lucacasonato/fresh/main/cli.ts
</pre>
<p class={tw`my-4 text-gray-600`}>
Once installed, you can use the `fresh` command to bootstrap a new
project:
</p>
<pre class={tw`overflow-x-auto py-2 px-4 bg(gray-100)`}>
fresh init my-app
</pre>
<p class={tw`my-4 text-gray-600`}>
Enter the newly created project directory and run the following command
to start the development server:
</p>
<pre class={tw`overflow-x-auto py-2 px-4 bg(gray-100)`}>
deno run -A --watch main.ts
</pre>
<p class={tw`my-4 text-gray-600`}>
You can now open{" "}
<a
href="http://localhost:8000"
class={tw`text-blue-500 hover:underline`}
>
http://localhost:8000
</a>{" "}
in your browser to view the page.
</p>
<p class={tw`my-4 text-gray-600`}>
A more in-depth getting started guide is available in{" "}
<a href="/docs" class={tw`text-blue-500 hover:underline`}>the docs</a>.
</p>
</section>
);
}
+16
View File
@@ -0,0 +1,16 @@
// DO NOT EDIT. This file is generated by `fresh`.
// This file SHOULD be checked into source version control.
// To update this file, run `fresh routes`.
import * as $0 from "./pages/index.tsx";
import * as $1 from "./pages/_render.ts";
const routes = {
pages: {
"./pages/index.tsx": $0,
"./pages/_render.ts": $1,
},
baseUrl: import.meta.url,
};
export default routes;
+1
View File
@@ -0,0 +1 @@
export * from "../server.ts";
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB