feat: add docs section to website (#108)
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
export * from "../runtime.ts";
|
||||
import { IS_BROWSER } from "../runtime.ts";
|
||||
import { setup, tw } from "https://esm.sh/twind@0.16.16";
|
||||
export { setup, tw };
|
||||
import { apply, setup, tw } from "https://esm.sh/twind@0.16.16";
|
||||
export { apply, setup, tw };
|
||||
if (IS_BROWSER) {
|
||||
setup({});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/** @jsx h */
|
||||
|
||||
import { apply, h, tw } from "../client_deps.ts";
|
||||
import {
|
||||
CATEGORIES,
|
||||
TableOfContentsCategory,
|
||||
TableOfContentsCategoryEntry,
|
||||
} from "../data/docs.ts";
|
||||
|
||||
export default function DocsSidebar(props: { path: string }) {
|
||||
return (
|
||||
<ol class={tw`list-decimal list-inside font-semibold` + " nested"}>
|
||||
{CATEGORIES.map((category) => (
|
||||
<SidebarCategory path={props.path} category={category} />
|
||||
))}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
|
||||
const link = apply`text(gray-900 hover:gray-600)`;
|
||||
const linkActive = apply`text(blue-600 hover:blue-500)`;
|
||||
|
||||
export function SidebarCategory(props: {
|
||||
path: string;
|
||||
category: TableOfContentsCategory;
|
||||
}) {
|
||||
const outerItem = tw`my-2 block`;
|
||||
const innerList = tw`pl-4 list-decimal` + " nested";
|
||||
|
||||
const { title, href, entries } = props.category;
|
||||
const outerLink = tw`${href == props.path ? linkActive : link} font-bold`;
|
||||
|
||||
return (
|
||||
<li class={outerItem}>
|
||||
<a href={href} class={outerLink}>{title}</a>
|
||||
{entries.length > 0 && (
|
||||
<ol class={innerList}>
|
||||
{entries.map((entry) => (
|
||||
<SidebarEntry path={props.path} entry={entry} />
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export function SidebarEntry(props: {
|
||||
path: string;
|
||||
entry: TableOfContentsCategoryEntry;
|
||||
}) {
|
||||
const innerItem = tw`my-0.5`;
|
||||
|
||||
const { title, href } = props.entry;
|
||||
const innerLink = tw`${href == props.path ? linkActive : link} font-normal`;
|
||||
return (
|
||||
<li class={innerItem}>
|
||||
<a href={href} class={innerLink}>{title}</a>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/** @jsx h */
|
||||
|
||||
import { h, tw } from "../client_deps.ts";
|
||||
|
||||
const LINKS = [
|
||||
{
|
||||
title: "Source",
|
||||
href: "https://github.com/lucacasonato/fresh",
|
||||
},
|
||||
];
|
||||
|
||||
export default function Footer() {
|
||||
const footer = tw
|
||||
`border(t-2 gray-200) bg-gray-100 h-32 flex flex-col gap-4 justify-center`;
|
||||
const inner = tw
|
||||
`mx-auto max-w-screen-lg flex items-center justify-center gap-8`;
|
||||
const linkStyle = tw`text-gray-600 hover:underline`;
|
||||
const copyright = tw`text(gray-600 center)`;
|
||||
return (
|
||||
<footer class={footer}>
|
||||
<div class={inner}>
|
||||
{LINKS.map((link) => (
|
||||
<a href={link.href} class={linkStyle}>
|
||||
{link.title}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div class={copyright}>
|
||||
<span>© {new Date().getFullYear()} the fresh authors</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/** @jsx h */
|
||||
|
||||
import { h, tw } from "../client_deps.ts";
|
||||
|
||||
export default 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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/** @jsx h */
|
||||
|
||||
import { h, tw } from "../client_deps.ts";
|
||||
|
||||
export default function WarningBanner() {
|
||||
const warning = tw`bg-yellow-100 border(1 yellow-200) p-4 mb-4`;
|
||||
return (
|
||||
<div class={warning}>
|
||||
⚠️ Do not use `fresh` for production usecases yet, unless you are very
|
||||
actively tracking the `fresh` repository for updates. The framework is
|
||||
still undergoing very frequent core functionality changes. You can expect
|
||||
a mostly stable release around the end of March 2022.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import RAW_TOC from "../../docs/toc.json" assert { type: "json" };
|
||||
|
||||
type RawTableOfContents = Record<string, RawTableOfContentsEntry>;
|
||||
|
||||
interface RawTableOfContentsEntry {
|
||||
title: string;
|
||||
pages?: [string, string][];
|
||||
}
|
||||
|
||||
export interface TableOfContentsEntry {
|
||||
slug: string;
|
||||
title: string;
|
||||
category?: string;
|
||||
href: string;
|
||||
file: string;
|
||||
}
|
||||
|
||||
export interface TableOfContentsCategory {
|
||||
title: string;
|
||||
href: string;
|
||||
entries: TableOfContentsCategoryEntry[];
|
||||
}
|
||||
|
||||
export interface TableOfContentsCategoryEntry {
|
||||
title: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export const TABLE_OF_CONTENTS: Record<string, TableOfContentsEntry> = {};
|
||||
export const CATEGORIES: TableOfContentsCategory[] = [];
|
||||
|
||||
for (const parent in (RAW_TOC as unknown as RawTableOfContents)) {
|
||||
const rawEntry = (RAW_TOC as unknown as RawTableOfContents)[parent];
|
||||
const href = `/docs/${parent}`;
|
||||
const file = `docs/${parent}/index.md`;
|
||||
const entry = {
|
||||
slug: parent,
|
||||
title: rawEntry.title,
|
||||
href,
|
||||
file,
|
||||
};
|
||||
TABLE_OF_CONTENTS[parent] = entry;
|
||||
const category: TableOfContentsCategory = {
|
||||
title: rawEntry.title,
|
||||
href,
|
||||
entries: [],
|
||||
};
|
||||
CATEGORIES.push(category);
|
||||
if (rawEntry.pages) {
|
||||
for (const [id, title] of rawEntry.pages) {
|
||||
const slug = `${parent}/${id}`;
|
||||
const href = `/docs/${slug}`;
|
||||
const file = `docs/${slug}.md`;
|
||||
const entry = { slug, title, category: parent, href, file };
|
||||
TABLE_OF_CONTENTS[slug] = entry;
|
||||
category.entries.push({
|
||||
title,
|
||||
href,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const SLUGS = Object.keys(TABLE_OF_CONTENTS);
|
||||
+6
-2
@@ -3,13 +3,17 @@
|
||||
// To update this file, run `fresh routes`.
|
||||
|
||||
import * as $0 from "./routes/_render.ts";
|
||||
import * as $1 from "./routes/index.tsx";
|
||||
import * as $1 from "./routes/gfm.css.ts";
|
||||
import * as $2 from "./routes/docs/[...slug].tsx";
|
||||
import * as $3 from "./routes/index.tsx";
|
||||
import * as $$0 from "./islands/Counter.tsx";
|
||||
|
||||
const manifest = {
|
||||
routes: {
|
||||
"./routes/_render.ts": $0,
|
||||
"./routes/index.tsx": $1,
|
||||
"./routes/gfm.css.ts": $1,
|
||||
"./routes/docs/[...slug].tsx": $2,
|
||||
"./routes/index.tsx": $3,
|
||||
},
|
||||
islands: {
|
||||
"./islands/Counter.tsx": $$0,
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
/** @jsx h */
|
||||
/** @jsxFrag Fragment */
|
||||
|
||||
import { apply, Fragment, h, Head, PageProps, tw } from "../../client_deps.ts";
|
||||
import { gfm, Handlers } from "../../server_deps.ts";
|
||||
import DocsSidebar from "../../components/DocsSidebar.tsx";
|
||||
import Footer from "../../components/Footer.tsx";
|
||||
import NavigationBar from "../../components/NavigationBar.tsx";
|
||||
import WarningBanner from "../../components/WarningBanner.tsx";
|
||||
import {
|
||||
SLUGS,
|
||||
TABLE_OF_CONTENTS,
|
||||
TableOfContentsEntry,
|
||||
} from "../../data/docs.ts";
|
||||
|
||||
interface Data {
|
||||
page: Page;
|
||||
}
|
||||
|
||||
interface Page extends TableOfContentsEntry {
|
||||
markdown: string;
|
||||
}
|
||||
|
||||
export const handler: Handlers<Data> = {
|
||||
async GET(_req, ctx) {
|
||||
const slug = ctx.params.slug;
|
||||
if (slug === "") {
|
||||
return new Response("", {
|
||||
status: 307,
|
||||
headers: { location: "/docs/introduction" },
|
||||
});
|
||||
}
|
||||
const entry = TABLE_OF_CONTENTS[slug];
|
||||
if (!entry) {
|
||||
return new Response("404 Page not found", {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
const url = new URL(`../../../${entry.file}`, import.meta.url);
|
||||
const markdown = await Deno.readTextFile(url);
|
||||
const page = { ...entry, markdown };
|
||||
const resp = ctx.render({ page });
|
||||
return resp;
|
||||
},
|
||||
};
|
||||
|
||||
export default function DocsPage(props: PageProps<Data>) {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{props.data.page?.title ?? "Not Found"} | fresh docs</title>
|
||||
<link rel="stylesheet" href="/gfm.css" />
|
||||
</Head>
|
||||
<Header />
|
||||
<NavigationBar active="/docs" />
|
||||
<Main path={props.url.pathname} page={props.data.page} />
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Header() {
|
||||
const header = tw`mx-auto max-w-screen-lg flex gap-3 justify-between`;
|
||||
const sidebarButton = tw
|
||||
`px-4 py-4 md:hidden border(l-2 gray-100) flex items-center hover:bg-gray-50`;
|
||||
return (
|
||||
<header class={header}>
|
||||
<div class={tw`p-4`}>
|
||||
<Title />
|
||||
</div>
|
||||
<label for="docs_sidebar" class={sidebarButton}>
|
||||
<svg
|
||||
class={tw`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>
|
||||
</svg>
|
||||
</label>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
function Title() {
|
||||
const title = tw`text(2xl gray-900) tracking-tight font-extrabold`;
|
||||
const pageName = tw`font-light`;
|
||||
const subtitle = tw`text(sm gray-600)`;
|
||||
return (
|
||||
<>
|
||||
<p class={title}>
|
||||
<a href="/">fresh</a> <span class={pageName}>docs</span>
|
||||
</p>
|
||||
<p class={subtitle}>The next-gen web framework.</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Main(props: { path: string; page: Page }) {
|
||||
const main = tw`mx-auto max-w-screen-lg px-4 flex gap-6`;
|
||||
return (
|
||||
<>
|
||||
<MobileSidebar path={props.path} />
|
||||
<div class={main}>
|
||||
<DesktopSidebar path={props.path} />
|
||||
<Content page={props.page} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MobileSidebar(props: { path: string }) {
|
||||
const container = tw`fixed inset-0 flex z-40 hidden` + " toggled";
|
||||
const backdrop = tw`absolute inset-0 bg-gray-600 opacity-75`;
|
||||
const sidebar = tw
|
||||
`relative flex-1 flex flex-col w-[16rem] h-full bg-white border(r-2 gray-100)`;
|
||||
const heading = tw`p-4 border(b-2 gray-100)`;
|
||||
const items = tw`pt-2 pb-16 px-4 overflow-x-auto`;
|
||||
return (
|
||||
<>
|
||||
<input
|
||||
type="checkbox"
|
||||
class={tw`hidden` + " toggle"}
|
||||
id="docs_sidebar"
|
||||
autocomplete="off"
|
||||
>
|
||||
</input>
|
||||
<div class={container}>
|
||||
<label class={backdrop} for="docs_sidebar" />
|
||||
<div class={sidebar}>
|
||||
<div class={heading}>
|
||||
<Title />
|
||||
</div>
|
||||
<nav class={items}>
|
||||
<DocsSidebar path={props.path} />
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function DesktopSidebar(props: { path: string }) {
|
||||
return (
|
||||
<nav
|
||||
class={tw
|
||||
`w-[16rem] flex-shrink-0 hidden md:block py-8 pr-4 border(r-2 gray-100)`}
|
||||
>
|
||||
<DocsSidebar path={props.path} />
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function Content(props: { page: Page }) {
|
||||
const main = tw`py-8 overflow-hidden`;
|
||||
const title = tw`text(4xl gray-900) tracking-tight font-extrabold mt-6`;
|
||||
const body = tw`mt-6`;
|
||||
const html = gfm.render(props.page.markdown);
|
||||
return (
|
||||
<main class={main}>
|
||||
<WarningBanner />
|
||||
<h1 class={title}>{props.page.title}</h1>
|
||||
<div
|
||||
class={`${body} markdown-body`}
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
<ForwardBackButtons slug={props.page.slug} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const button = apply`p-2 bg-gray-100 w-full border(1 gray-200) grid`;
|
||||
|
||||
function ForwardBackButtons(props: { slug: string }) {
|
||||
const currentIndex = SLUGS.findIndex((slug) => slug === props.slug);
|
||||
const previousSlug = SLUGS[currentIndex - 1];
|
||||
const nextSlug = SLUGS[currentIndex + 1];
|
||||
const previous = TABLE_OF_CONTENTS[previousSlug];
|
||||
const next = TABLE_OF_CONTENTS[nextSlug];
|
||||
|
||||
const upper = tw`text(sm gray-600)`;
|
||||
const category = tw`font-normal`;
|
||||
const lower = tw`text-gray-900 font-medium`;
|
||||
|
||||
return (
|
||||
<div class={tw`mt-8 flex flex(col md:row) gap-4`}>
|
||||
{previous && (
|
||||
<a href={previous.href} class={tw`${button} text-left`}>
|
||||
<span class={upper}>{"<-"} Previous</span>
|
||||
<span class={lower}>
|
||||
<span class={category}>
|
||||
{previous.category
|
||||
? `${TABLE_OF_CONTENTS[previous.category].title}: `
|
||||
: ""}
|
||||
</span>
|
||||
{previous.title}
|
||||
</span>
|
||||
</a>
|
||||
)}
|
||||
{next && (
|
||||
<a href={next.href} class={tw`${button} text-right`}>
|
||||
<span class={upper}>Next {"->"}</span>
|
||||
<span class={lower}>
|
||||
<span class={category}>
|
||||
{next.category
|
||||
? `${TABLE_OF_CONTENTS[next.category].title}: `
|
||||
: ""}
|
||||
</span>
|
||||
{next.title}
|
||||
</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { gfm, Handlers } from "../server_deps.ts";
|
||||
|
||||
// TODO(lucacasonato): hash the file and use the hash as the filename, and serve
|
||||
// with high-cacheability headers.
|
||||
|
||||
const CSS = `${gfm.CSS}
|
||||
|
||||
ol.nested {
|
||||
counter-reset: item;
|
||||
}
|
||||
|
||||
ol.nested li {
|
||||
display: block;
|
||||
}
|
||||
|
||||
ol.nested li:before {
|
||||
font-feature-settings: "kern" 1, "tnum" 1;
|
||||
-webkit-font-feature-settings: "kern" 1, "tnum" 1;
|
||||
-ms-font-feature-settings: "kern" 1, "tnum" 1;
|
||||
-moz-font-feature-settings: "kern" 1, "tnum" 1;
|
||||
content: counters(item, ".") ". ";
|
||||
counter-increment: item;
|
||||
}
|
||||
|
||||
.markdown-body ul {
|
||||
list-style: disc;
|
||||
}
|
||||
|
||||
.markdown-body ol {
|
||||
list-style: numeric;
|
||||
}
|
||||
|
||||
.toggle:checked + .toggled {
|
||||
display: block;
|
||||
}
|
||||
`;
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET: () => {
|
||||
return new Response(CSS, {
|
||||
headers: {
|
||||
"content-type": "text/css",
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
+26
-49
@@ -3,6 +3,9 @@
|
||||
|
||||
import { Fragment, h, Head, tw } from "../client_deps.ts";
|
||||
import Counter from "../islands/Counter.tsx";
|
||||
import NavigationBar from "../components/NavigationBar.tsx";
|
||||
import Footer from "../components/Footer.tsx";
|
||||
import WarningBanner from "../components/WarningBanner.tsx";
|
||||
|
||||
export default function MainPage() {
|
||||
return (
|
||||
@@ -19,6 +22,7 @@ export default function MainPage() {
|
||||
<Intro />
|
||||
<GettingStarted />
|
||||
<Example />
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -27,7 +31,7 @@ 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 center) sm:tracking-tight font-extrabold`;
|
||||
const subtitle = tw`mt-4 text(2xl gray-600)`;
|
||||
const subtitle = tw`mt-4 text(2xl gray-600 center)`;
|
||||
|
||||
return (
|
||||
<section class={container}>
|
||||
@@ -41,46 +45,16 @@ function Hero() {
|
||||
);
|
||||
}
|
||||
|
||||
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`}>
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<p class={tw`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`}>
|
||||
<ul class={tw`text-gray-600 list-disc list-inside pl-4`}>
|
||||
<li>
|
||||
<b>Just-in-time rendering</b> on the edge.
|
||||
</li>
|
||||
@@ -101,9 +75,9 @@ function Intro() {
|
||||
<b>TypeScript support</b> out of the box.
|
||||
</li>
|
||||
</ul>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
Fresh embraces the tried and true design of server side rendering and
|
||||
processing.
|
||||
progressive enhancement on the client side.
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
@@ -111,41 +85,44 @@ function Intro() {
|
||||
|
||||
function GettingStarted() {
|
||||
return (
|
||||
<section class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8)`}>
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<h2 id="getting-started" class={tw`text(xl gray-600) font-bold`}>
|
||||
<a href="#getting-started" class={tw`hover:underline`}>
|
||||
Getting started
|
||||
</a>
|
||||
</h2>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<WarningBanner />
|
||||
<p class={tw`text-gray-600`}>
|
||||
To get started, make sure you have the{" "}
|
||||
<a href="https://deno.land" class={tw`text-blue-600 hover:underline`}>
|
||||
Deno CLI
|
||||
</a>{" "}
|
||||
installed.
|
||||
</p>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`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`}>
|
||||
<p class={tw`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`}>
|
||||
<p class={tw`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`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
You can now open{" "}
|
||||
<a
|
||||
href="http://localhost:8000"
|
||||
@@ -155,7 +132,7 @@ function GettingStarted() {
|
||||
</a>{" "}
|
||||
in your browser to view the page.
|
||||
</p>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
A more in-depth getting started guide is available in{" "}
|
||||
<a href="/docs" class={tw`text-blue-600 hover:underline`}>the docs</a>.
|
||||
</p>
|
||||
@@ -171,25 +148,25 @@ const timeFmt = new Intl.DateTimeFormat("en-US", {
|
||||
function Example() {
|
||||
return (
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8)`}
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<h2 id="example" class={tw`text(xl gray-600) font-bold`}>
|
||||
<a href="#example" class={tw`hover:underline`}>
|
||||
Example
|
||||
</a>
|
||||
</h2>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
This text is being server side rendered on the fly. It was rendered at
|
||||
{" "}
|
||||
{timeFmt.format(new Date())}.
|
||||
</p>
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
The counter below was rendered on the server with a starting value of 3,
|
||||
and was then hydrated on the client to provide interactivity. Try out
|
||||
the buttons!
|
||||
</p>
|
||||
<Counter start={3} />
|
||||
<p class={tw`my-4 text-gray-600`}>
|
||||
<p class={tw`text-gray-600`}>
|
||||
Only the JS required to render that counter is sent to the client.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
export * from "../server.ts";
|
||||
|
||||
export { virtualSheet } from "https://esm.sh/twind@0.16.16/sheets";
|
||||
|
||||
export * as gfm from "https://deno.land/x/gfm@0.1.19/mod.ts";
|
||||
import "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check";
|
||||
import "https://esm.sh/prismjs@1.27.0/components/prism-typescript.js?no-check";
|
||||
import "https://esm.sh/prismjs@1.27.0/components/prism-tsx.js?no-check";
|
||||
|
||||
Reference in New Issue
Block a user