toc: false
Diplodocus
Diplodocus is Static Assets Serving System only for Deno Deploy.
βDiplodocusβ sounds like βDeploy docsβ a littleβ¦?
- Serve the assets on the GitHub repository
- Parse the Markdown files to HTML pages
Quick start
Create docs
directly and some markdown pages.
βββ docs/
β βββ about.md
β βββ index.md
β βββ pages/
β βββ 01.md
β βββ 02.md
β βββ 03.md
βββ server.ts
Add links in index.md
.
# index
- [about](/about)
- [page 01](/page/01)
- [page 02](/page/02)
- [page 03](/page/03)
Create server.ts
. This is almost same as a sample script of
Deno Deploy Beta 2.
// server.ts
import { Diplodocus } from "https://deno.land/x/diplodocus/mod.ts";
const diplodocus = await Diplodocus.load();
const port = 8080;
const listener = Deno.listen({ port });
console.log(`HTTP server listening on http://localhost:${port}`);
async function handleConn(conn: Deno.Conn) {
const httpConn = Deno.serveHttp(conn);
for await (const e of httpConn) {
e.respondWith(diplodocus.handler(e.request));
}
}
for await (const conn of listener) {
handleConn(conn);
}
Run server.ts
by deno run
or
deployctl and access to the local
server.
$ deno run --allow-net --allow-read --no-check ./server.ts
$ # deplyctl run --no-check ./server.ts