www: add versioning to docs (#1400)

This commit is contained in:
Marvin Hagemeister
2023-07-04 12:33:47 +02:00
committed by GitHub
parent efcaec3658
commit bf3e82c093
10 changed files with 566 additions and 149 deletions
+15
View File
@@ -0,0 +1,15 @@
---
description: |
Learn more about Fresh canary releases
---
The canary version represents the current development state of Fresh. It's
intended for testing work in progress features before it lands in a stable
release. Whenever new code is merged into the `main` branch on
[GitHub](https://github.com/denoland/fresh) a new canary version is created that
matches the hash of the git commit.
With the addition of new features that are not yet in a stable release, we need
a place to update our documentation. That's what this section of the
documentation is about. It contains all information about unreleased features
and changes that will land in a stable release.
+151 -56
View File
@@ -1,66 +1,161 @@
type RawTableOfContents = Record<string, RawTableOfContentsEntry>;
import FRESH_VERSIONS from "../versions.json" assert { type: "json" };
type RawTableOfContents = Record<
string,
{
label: string;
content: Record<string, RawTableOfContentsEntry>;
}
>;
interface RawTableOfContentsEntry {
title: string;
pages?: [string, string][];
link?: string;
pages?: [string, string, string?][];
}
const toc: RawTableOfContents = {
"introduction": {
"title": "Introduction",
canary: {
label: "canary",
content: {
"the-canary-version": {
title: "The canary version",
},
introduction: {
title: "Introduction",
link: "latest",
},
"getting-started": {
title: "Getting Started",
link: "latest",
pages: [
["create-a-project", "Create a project", "link:latest"],
["running-locally", "Running locally", "link:latest"],
["create-a-route", "Create a route", "link:latest"],
["dynamic-routes", "Dynamic routes", "link:latest"],
["custom-handlers", "Custom handlers", "link:latest"],
["fetching-data", "Fetching data", "link:latest"],
["form-submissions", "Form submissions", "link:latest"],
["adding-interactivity", "Adding interactivity", "link:latest"],
["deploy-to-production", "Deploy to production", "link:latest"],
],
},
concepts: {
title: "Concepts",
link: "latest",
pages: [
["architecture", "Architecture", "link:latest"],
["routes", "Routes", "link:latest"],
["forms", "Forms", "link:latest"],
["islands", "Interactive islands", "link:latest"],
["static-files", "Static files", "link:latest"],
["middleware", "Route middleware", "link:latest"],
["error-pages", "Error pages", "link:latest"],
["routing", "Routing", "link:latest"],
["data-fetching", "Data fetching", "link:latest"],
["deployment", "Deployment", "link:latest"],
["plugins", "Plugins", "link:latest"],
["updating", "Updating Fresh", "link:latest"],
["app-wrapper", "Application wrapper", "link:latest"],
["server-configuration", "Server configuration", "link:latest"],
],
},
integrations: {
title: "Integrations",
link: "latest",
},
examples: {
title: "Examples",
link: "latest",
pages: [
["modifying-the-head", "Modifying the <head>", "link:latest"],
["setting-the-language", "Setting the language", "link:latest"],
["writing-tests", "Writing tests", "link:latest"],
[
"changing-the-src-dir",
"Changing the source directory",
"link:latest",
],
["using-twind-v1", "Using Twind v1", "link:latest"],
["init-the-server", "Initializing the server", "link:latest"],
[
"using-fresh-canary-version",
"Using Fresh canary version",
"link:latest",
],
["dealing-with-cors", "Dealing with CORS", "link:latest"],
["creating-a-crud-api", "Creating a CRUD API", "link:latest"],
["handling-complex-routes", "Handling complex routes", "link:latest"],
["rendering-markdown", "Rendering markdown", "link:latest"],
[
"sharing-state-between-islands",
"Sharing state between islands",
"link:latest",
],
],
},
},
},
"getting-started": {
"title": "Getting Started",
"pages": [
["create-a-project", "Create a project"],
["running-locally", "Running locally"],
["create-a-route", "Create a route"],
["dynamic-routes", "Dynamic routes"],
["custom-handlers", "Custom handlers"],
["fetching-data", "Fetching data"],
["form-submissions", "Form submissions"],
["adding-interactivity", "Adding interactivity"],
["deploy-to-production", "Deploy to production"],
],
},
"concepts": {
"title": "Concepts",
"pages": [
["architecture", "Architecture"],
["routes", "Routes"],
["forms", "Forms"],
["islands", "Interactive islands"],
["static-files", "Static files"],
["middleware", "Route middleware"],
["error-pages", "Error pages"],
["routing", "Routing"],
["data-fetching", "Data fetching"],
["deployment", "Deployment"],
["plugins", "Plugins"],
["updating", "Updating Fresh"],
["app-wrapper", "Application wrapper"],
["server-configuration", "Server configuration"],
],
},
"integrations": {
"title": "Integrations",
},
"examples": {
"title": "Examples",
"pages": [
["modifying-the-head", "Modifying the <head>"],
["setting-the-language", "Setting the language"],
["writing-tests", "Writing tests"],
["changing-the-src-dir", "Changing the source directory"],
["using-twind-v1", "Using Twind v1"],
["init-the-server", "Initializing the server"],
["using-fresh-canary-version", "Using Fresh canary version"],
["dealing-with-cors", "Dealing with CORS"],
["creating-a-crud-api", "Creating a CRUD API"],
["handling-complex-routes", "Handling complex routes"],
["rendering-markdown", "Rendering markdown"],
["sharing-state-between-islands", "Sharing state between islands"],
],
latest: {
label: FRESH_VERSIONS[0],
content: {
introduction: {
title: "Introduction",
},
"getting-started": {
title: "Getting Started",
pages: [
["create-a-project", "Create a project"],
["running-locally", "Running locally"],
["create-a-route", "Create a route"],
["dynamic-routes", "Dynamic routes"],
["custom-handlers", "Custom handlers"],
["fetching-data", "Fetching data"],
["form-submissions", "Form submissions"],
["adding-interactivity", "Adding interactivity"],
["deploy-to-production", "Deploy to production"],
],
},
concepts: {
title: "Concepts",
pages: [
["architecture", "Architecture"],
["routes", "Routes"],
["forms", "Forms"],
["islands", "Interactive islands"],
["static-files", "Static files"],
["middleware", "Route middleware"],
["error-pages", "Error pages"],
["routing", "Routing"],
["data-fetching", "Data fetching"],
["deployment", "Deployment"],
["plugins", "Plugins"],
["updating", "Updating Fresh"],
["app-wrapper", "Application wrapper"],
["server-configuration", "Server configuration"],
],
},
integrations: {
title: "Integrations",
},
examples: {
title: "Examples",
pages: [
["modifying-the-head", "Modifying the <head>"],
["setting-the-language", "Setting the language"],
["writing-tests", "Writing tests"],
["changing-the-src-dir", "Changing the source directory"],
["using-twind-v1", "Using Twind v1"],
["init-the-server", "Initializing the server"],
["using-fresh-canary-version", "Using Fresh canary version"],
["dealing-with-cors", "Dealing with CORS"],
["creating-a-crud-api", "Creating a CRUD API"],
["handling-complex-routes", "Handling complex routes"],
["rendering-markdown", "Rendering markdown"],
["sharing-state-between-islands", "Sharing state between islands"],
],
},
},
},
};
+18 -4
View File
@@ -1,13 +1,20 @@
import { Head } from "$fresh/runtime.ts";
import {
CATEGORIES,
TableOfContentsCategory,
TableOfContentsCategoryEntry,
} from "../data/docs.ts";
import SearchButton from "../islands/SearchButton.tsx";
import VersionSelect from "../islands/VersionSelect.tsx";
import { type VersionLink } from "../routes/docs/[...slug].tsx";
export default function DocsSidebar(props: { path: string; mobile?: boolean }) {
const id = String(Math.random()).replaceAll(".", "");
export default function DocsSidebar(
props: {
path: string;
mobile?: boolean;
versionLinks: VersionLink[];
selectedVersion: string;
},
) {
return (
<>
{props.mobile
@@ -47,8 +54,15 @@ export default function DocsSidebar(props: { path: string; mobile?: boolean }) {
)
: <SearchButton />}
<div class="mb-4">
<VersionSelect
selectedVersion={props.selectedVersion}
versions={props.versionLinks}
/>
</div>
<ol class="list-decimal list-inside font-semibold nested">
{CATEGORIES.map((category) => (
{CATEGORIES[props.selectedVersion].map((category) => (
<SidebarCategory path={props.path} category={category} />
))}
</ol>
+75 -34
View File
@@ -19,42 +19,83 @@ export interface TableOfContentsCategoryEntry {
href: string;
}
export const TABLE_OF_CONTENTS: Record<string, TableOfContentsEntry> = {};
export const CATEGORIES: TableOfContentsCategory[] = [];
export const TABLE_OF_CONTENTS: Record<
string,
Record<string, TableOfContentsEntry>
> = {};
export const CATEGORIES: Record<string, TableOfContentsCategory[]> = {};
for (const parent in toc) {
const rawEntry = toc[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);
const filteredPages = rawEntry.pages?.filter(([title, page]) =>
title != null && page != null
);
if (filteredPages) {
for (const [id, title] of filteredPages) {
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 VERSIONS = Object.keys(toc);
export const CANARY_VERSION = toc.canary ? "canary" : "";
export const LATEST_VERSION =
VERSIONS.find((version) => version !== "canary") ?? "";
for (const version in toc) {
const RAW_VERSION = toc[version];
const versionSlug = version === LATEST_VERSION ? "" : `/${version}`;
TABLE_OF_CONTENTS[version] = {};
CATEGORIES[version] = [];
for (const parent in RAW_VERSION.content) {
const rawEntry = RAW_VERSION.content[parent];
// Allow versioned documentation to stack on each other. This should
// only be used for canary versions. This avoids having us to copy
// all documentation content and backport changes.
const fileVersion = rawEntry.link ?? version;
const versionFilePath = fileVersion === LATEST_VERSION
? ""
: `/${fileVersion}`;
const href = `/docs${versionSlug}/${parent}`;
const file = `docs${versionFilePath}/${parent}/index.md`;
const entry = {
slug: parent,
title: rawEntry.title,
href,
file,
};
TABLE_OF_CONTENTS[version][parent] = entry;
const category: TableOfContentsCategory = {
title: rawEntry.title,
href,
entries: [],
};
CATEGORIES[version].push(category);
if (rawEntry.pages) {
for (const [id, title, linkedVersion] of rawEntry.pages) {
const slug = `${parent}/${id}`;
// Allow stacked documentation
const pageVersion = linkedVersion
? linkedVersion.slice("link:".length)
: version;
const versionFilePath = !pageVersion || pageVersion === LATEST_VERSION
? ""
: `/${pageVersion}`;
const href = `/docs${versionSlug}/${slug}`;
const file = `docs${versionFilePath}/${slug}.md`;
const entry = { slug, title, category: parent, href, file };
TABLE_OF_CONTENTS[version][slug] = entry;
category.entries.push({
title,
href,
});
}
}
}
}
export const SLUGS = Object.keys(TABLE_OF_CONTENTS);
export function getFirstPageUrl(version: string) {
const group = TABLE_OF_CONTENTS[version];
if (group) {
for (const slug in group) {
return group[slug].href;
}
}
throw new Error(`Could not find version "${version}"`);
}
+14 -10
View File
@@ -7,16 +7,18 @@ import * as $1 from "./routes/_500.tsx";
import * as $2 from "./routes/_middleware.ts";
import * as $3 from "./routes/components.tsx";
import * as $4 from "./routes/docs/[...slug].tsx";
import * as $5 from "./routes/gfm.css.ts";
import * as $6 from "./routes/index.tsx";
import * as $7 from "./routes/raw.ts";
import * as $8 from "./routes/showcase.tsx";
import * as $9 from "./routes/update.tsx";
import * as $5 from "./routes/docs/index.tsx";
import * as $6 from "./routes/gfm.css.ts";
import * as $7 from "./routes/index.tsx";
import * as $8 from "./routes/raw.ts";
import * as $9 from "./routes/showcase.tsx";
import * as $10 from "./routes/update.tsx";
import * as $$0 from "./islands/ComponentGallery.tsx";
import * as $$1 from "./islands/CopyArea.tsx";
import * as $$2 from "./islands/Counter.tsx";
import * as $$3 from "./islands/LemonDrop.tsx";
import * as $$4 from "./islands/SearchButton.tsx";
import * as $$5 from "./islands/VersionSelect.tsx";
const manifest = {
routes: {
@@ -25,11 +27,12 @@ const manifest = {
"./routes/_middleware.ts": $2,
"./routes/components.tsx": $3,
"./routes/docs/[...slug].tsx": $4,
"./routes/gfm.css.ts": $5,
"./routes/index.tsx": $6,
"./routes/raw.ts": $7,
"./routes/showcase.tsx": $8,
"./routes/update.tsx": $9,
"./routes/docs/index.tsx": $5,
"./routes/gfm.css.ts": $6,
"./routes/index.tsx": $7,
"./routes/raw.ts": $8,
"./routes/showcase.tsx": $9,
"./routes/update.tsx": $10,
},
islands: {
"./islands/ComponentGallery.tsx": $$0,
@@ -37,6 +40,7 @@ const manifest = {
"./islands/Counter.tsx": $$2,
"./islands/LemonDrop.tsx": $$3,
"./islands/SearchButton.tsx": $$4,
"./islands/VersionSelect.tsx": $$5,
},
baseUrl: import.meta.url,
};
+62
View File
@@ -0,0 +1,62 @@
// 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";
export default function VersionSelect(
{ versions, selectedVersion }: {
versions: VersionLink[];
selectedVersion: string;
},
) {
const selectedIsLatest = selectedVersion === "latest";
const selectedIsCanary = selectedVersion === "canary";
return (
<>
<div class="relative">
<label htmlFor="version" class="sr-only">
Version
</label>
{selectedIsLatest && (
<div class="flex absolute pointer-events-none select-none w-full h-full items-center justify-end pr-8">
<div class="rounded-full px-2 py-1 text-xs tag-label bg-[#056CF025] text-blue-600">
Latest
</div>
</div>
)}
{selectedIsCanary && (
<div class="flex absolute pointer-events-none select-none w-full h-full items-center justify-end pr-8">
<div class="rounded-full px-2 py-1 text-xs tag-label bg-[#F0900525] text-yellow-600">
🚧 Preview
</div>
</div>
)}
<select
id="version"
class={`rounded-md block border border-gray-300 appearance-none bg-white form-select-bg font-semibold ${
selectedIsLatest ? "pr-22" : "pr-10"
} py-2 pl-3 w-full h-full leading-none sm:(text-sm leading-5) focus:(outline-none border-blue-300) hover:bg-gray-100`}
value={selectedVersion}
onChange={(e) => {
if (e.currentTarget.value !== selectedVersion) {
const entry = versions.find((entry) =>
entry.value === e.currentTarget.value
);
if (entry) {
location.href = entry.href;
}
}
}}
disabled={!IS_BROWSER}
>
{versions.map((entry) => (
<option key={entry.value} value={entry.value}>
{entry.label}
</option>
))}
</select>
</div>
</>
);
}
+61 -3
View File
@@ -1,12 +1,15 @@
import { assertEquals } from "$std/testing/asserts.ts";
import { assertArrayIncludes, assertEquals } from "$std/testing/asserts.ts";
import { delay } from "$std/async/delay.ts";
import { startFreshServer } from "../tests/test_utils.ts";
import { startFreshServer, withPageName } from "../tests/test_utils.ts";
import { dirname, join } from "$std/path/mod.ts";
const dir = dirname(import.meta.url);
Deno.test("CORS should not set on GET /fresh-badge.svg", {
sanitizeResources: false,
}, async () => {
const { serverProcess, lines, address } = await startFreshServer({
args: ["run", "-A", "./main.ts"],
args: ["run", "-A", join(dir, "./main.ts")],
});
const res = await fetch(`${address}/fresh-badge.svg`);
@@ -19,3 +22,58 @@ Deno.test("CORS should not set on GET /fresh-badge.svg", {
// await for the server to close
await delay(100);
});
Deno.test("shows version selector", {
sanitizeResources: false,
}, async () => {
await withPageName(join(dir, "./main.ts"), 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`);
// 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,
}));
});
assertEquals(options.length, 2);
assertArrayIncludes(options, [
{
value: "canary",
label: "canary",
},
{
value: "1.2",
label: "1.2.x",
},
]);
const selectValue = await page.$eval(
"#version",
(el: HTMLSelectElement) => el.value,
);
assertEquals(selectValue, "1.2");
// 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`);
});
});
+136 -41
View File
@@ -1,52 +1,135 @@
import { asset, Head } from "$fresh/runtime.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
import { frontMatter, gfm } from "../../utils/markdown.ts";
import Header from "../../components/Header.tsx";
import DocsTitle from "../../components/DocsTitle.tsx";
import { asset, Head } from "$fresh/runtime.ts";
import DocsSidebar from "../../components/DocsSidebar.tsx";
import DocsTitle from "../../components/DocsTitle.tsx";
import Footer from "../../components/Footer.tsx";
import Header from "../../components/Header.tsx";
import {
SLUGS,
getFirstPageUrl,
LATEST_VERSION,
TABLE_OF_CONTENTS,
TableOfContentsEntry,
} from "../../data/docs.ts";
import { frontMatter, gfm } from "../../utils/markdown.ts";
import toc from "../../../docs/toc.ts";
interface Data {
page: Page;
}
interface NavEntry {
title: string;
category?: string;
href: string;
}
export interface VersionLink {
label: string;
href: string;
value: string;
}
interface Page extends TableOfContentsEntry {
markdown: string;
data: Record<string, unknown>;
versionLinks: VersionLink[];
version: string;
prevNav?: NavEntry;
nextNav?: NavEntry;
}
const pattern = new URLPattern({ pathname: "/:version/:page*" });
export const handler: Handlers<Data> = {
async GET(_req, ctx) {
const slug = ctx.params.slug;
if (slug === "") {
// Check if the slug is the index page of a version tag
if (TABLE_OF_CONTENTS[slug]) {
const href = getFirstPageUrl(slug);
return new Response("", {
status: 307,
headers: { location: "/docs/introduction" },
});
}
if (slug === "concepts/architechture") {
return new Response("", {
status: 307,
headers: { location: "/docs/concepts/architecture" },
headers: { location: href },
});
}
const entry = TABLE_OF_CONTENTS[slug];
const match = pattern.exec("https://localhost/" + slug);
if (!match) {
return ctx.renderNotFound();
}
let { version, page = "" } = match.pathname.groups;
if (!version) {
return ctx.renderNotFound();
}
// Latest version doesn't show up in the url
if (!TABLE_OF_CONTENTS[version]) {
page = version + (page ? "/" + page : "");
version = LATEST_VERSION;
}
// Check if the page exists
const currentToc = TABLE_OF_CONTENTS[version];
const entry = currentToc[page];
if (!entry) {
return ctx.renderNotFound();
}
// Build up the link map for the version selector.
const versionLinks: VersionLink[] = [];
for (const version in TABLE_OF_CONTENTS) {
const label = toc[version].label;
const maybeEntry = TABLE_OF_CONTENTS[version][page];
// Check if the same page is available for this version and
// link to that. Pick the index page for that version if an
// exact match doesn't exist.
versionLinks.push({
label,
value: version,
href: maybeEntry ? maybeEntry.href : getFirstPageUrl(version),
});
}
// Add previous and next page entry if available
const entryKeys = Object.keys(currentToc);
const idx = entryKeys.findIndex((name) => name === entry.slug);
let nextNav: NavEntry | undefined;
let prevNav: NavEntry | undefined;
const prevEntry = currentToc[entryKeys[idx - 1]];
const nextEntry = currentToc[entryKeys[idx + 1]];
if (prevEntry) {
let category = prevEntry.category;
category = category ? currentToc[category].title : "";
prevNav = { title: prevEntry.title, category, href: prevEntry.href };
}
if (nextEntry) {
let category = nextEntry.category;
category = category ? currentToc[category].title : "";
nextNav = { title: nextEntry.title, category, href: nextEntry.href };
}
// Parse markdown front matter
const url = new URL(`../../../${entry.file}`, import.meta.url);
const fileContent = await Deno.readTextFile(url);
const { body, attrs } = frontMatter<Record<string, unknown>>(fileContent);
const page = { ...entry, markdown: body, data: attrs ?? {} };
const resp = ctx.render({ page });
return resp;
return ctx.render({
page: {
...entry,
markdown: body,
data: attrs ?? {},
versionLinks,
version,
prevNav,
nextNav,
},
});
},
};
@@ -84,7 +167,7 @@ export default function DocsPage(props: PageProps<Data>) {
function Main(props: { path: string; page: Page }) {
return (
<div class="flex-1">
<MobileSidebar path={props.path} />
<MobileSidebar path={props.path} page={props.page} />
<div class="flex mx-auto max-w-screen-lg px-4 py-5 justify-end">
<label
for="docs_sidebar"
@@ -110,14 +193,14 @@ function Main(props: { path: string; page: Page }) {
</label>
</div>
<div class="mx-auto max-w-screen-lg px-4 flex gap-6">
<DesktopSidebar path={props.path} />
<DesktopSidebar path={props.path} page={props.page} />
<Content page={props.page} />
</div>
</div>
);
}
function MobileSidebar(props: { path: string }) {
function MobileSidebar(props: { path: string; page: Page }) {
return (
<>
<input
@@ -137,7 +220,12 @@ function MobileSidebar(props: { path: string }) {
<DocsTitle title="docs" />
</div>
<nav class="pt-6 pb-16 px-4 overflow-x-auto">
<DocsSidebar mobile path={props.path} />
<DocsSidebar
mobile
path={props.path}
versionLinks={props.page.versionLinks}
selectedVersion={props.page.version}
/>
</nav>
</div>
</div>
@@ -145,10 +233,14 @@ function MobileSidebar(props: { path: string }) {
);
}
function DesktopSidebar(props: { path: string }) {
function DesktopSidebar(props: { path: string; page: Page }) {
return (
<nav class="w-[16rem] flex-shrink-0 hidden md:block py-8 pr-4 border(r-2 gray-100)">
<DocsSidebar path={props.path} />
<DocsSidebar
path={props.path}
versionLinks={props.page.versionLinks}
selectedVersion={props.page.version}
/>
</nav>
);
}
@@ -164,36 +256,41 @@ function Content(props: { page: Page }) {
class="mt-6 markdown-body"
dangerouslySetInnerHTML={{ __html: html }}
/>
<ForwardBackButtons slug={props.page.slug} />
<ForwardBackButtons
slug={props.page.slug}
version={props.page.version}
prev={props.page.prevNav}
next={props.page.nextNav}
/>
</main>
);
}
const button = "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];
function ForwardBackButtons(
props: {
slug: string;
version: string;
prev?: NavEntry;
next?: NavEntry;
},
) {
const { prev, next } = props;
const upper = "text(sm gray-600)";
const category = "font-normal";
const lower = "text-gray-900 font-medium";
return (
<div class="mt-8 flex flex(col md:row) gap-4">
{previous && (
<a href={previous.href} class={`${button} text-left`}>
{prev && (
<a href={prev.href} class={`${button} text-left`}>
<span class={upper}>{"←"} Previous</span>
<span class={lower}>
<span class={category}>
{previous.category
? `${TABLE_OF_CONTENTS[previous.category].title}: `
: ""}
{prev.category ? `${prev.category}: ` : ""}
</span>
{previous.title}
{prev.title}
</span>
</a>
)}
@@ -202,9 +299,7 @@ function ForwardBackButtons(props: { slug: string }) {
<span class={upper}>Next {"→"}</span>
<span class={lower}>
<span class={category}>
{next.category
? `${TABLE_OF_CONTENTS[next.category].title}: `
: ""}
{next.category ? `${next.category}: ` : ""}
</span>
{next.title}
</span>
+19
View File
@@ -0,0 +1,19 @@
import { MultiHandler } from "$fresh/server.ts";
export const handler: MultiHandler<void> = {
GET(_req, ctx) {
const slug = ctx.params.slug;
if (slug === "concepts/architechture") {
return new Response("", {
status: 307,
headers: { location: "/docs/concepts/architecture" },
});
}
return new Response("", {
status: 307,
headers: { location: "/docs/introduction" },
});
},
};
+15 -1
View File
@@ -17,7 +17,7 @@ export default {
plugins: {
// Basic workaround for old twind version not supporting
// the `basis-*` keyword
"basis": (parts) => {
basis: (parts) => {
let value;
const arr = parts[0].split("/");
if (arr.length === 2) {
@@ -29,5 +29,19 @@ export default {
"flex-basis": value,
};
},
"rounded-full": () => {
return {
"border-radius": "9999px",
};
},
"form-select-bg": () => {
return {
"background-image":
`url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3e%3cpath d='M7 7l3-3 3 3m0 6l-3 3-3-3' stroke='%239fa6b2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e")`,
"background-position": "right 0.5rem center",
"background-size": "1.5em 1.5em",
"background-repeat": "no-repeat",
};
},
},
} as Options;