Skip to content

Commit

Permalink
chore(website): add /docs page
Browse files Browse the repository at this point in the history
also adds support for redirection to latest version for bare `/docs` requests
  • Loading branch information
gabeidx committed Jul 15, 2022
1 parent 4466bbd commit ce6456f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions website/docs/0.x/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- title: Documentation (0.x) — Atlas -->
<!-- meta_description: Learn how to use the Atlas framework version 0.x -->
<main class="prose prose-neutral dark:prose-invert flex flex-col items-start space-y-4 px-4 py-2 md:py-4 lg:px-8 lg:py-6">
<header>
<h1>Documentation (0.x)</h1>
</header>

<p><code>// TODO</code></p>
</main>
15 changes: 15 additions & 0 deletions website/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ async function handler(request: Request): Promise<Response> {
...headers,
"location": `https://doc.deno.land/https://deno.land/x/atlas${mod}`,
};
} // docs
else if (pathname === "/docs") {
const versions = [];
for await (const entry of Deno.readDir(`${cwd}/${pathname}`)) {
if (entry.isDirectory) {
versions.push(entry);
}
}

status = 307;
headers = {
...headers,
// redirect to latest version
"location": `/docs/${versions.at(-1)?.name}`,
};
} // other routes
else {
// try /[route].html first
Expand Down

0 comments on commit ce6456f

Please sign in to comment.