~tychi/code-mirror-shield

ba2ad21f9fc433cf40ea4cffb65347ccea2eff51 — Tyler Childs 7 months ago d14fedb
feature: parse a markdown file readme for the homepage
4 files changed, 32 insertions(+), 2 deletions(-)

A README.md
A public/index.html
M server.js
M server.lock.json
A README.md => README.md +11 -0
@@ 0,0 1,11 @@
# Welcome. Play nice.

This is a digital garden. It is yours.

1. Stop
1. Drop
1. Hammer time

You _can_ touch this. And click it. Or **clack** it.

Any machine that'll survive past [y2k38](https://y2k38.info) will do.

A public/index.html => public/index.html +1 -0
@@ 0,0 1,1 @@
hello
\ No newline at end of file

M server.js => server.js +13 -1
@@ 1,4 1,7 @@
import { serve } from "https://deno.land/std@0.114.0/http/server.ts";
import { serve }
	from "https://deno.land/std@0.114.0/http/server.ts";
import { parseMarkdown }
	from "https://deno.land/x/markdown_wasm/mod.ts"

const methods = {
	'GET': handleGet,


@@ 39,6 42,15 @@ async function handleGet(request) {
	const isAutosave = pathname.split('.').slice(-1) === 'autosave'
	const extensionPosition = isAutosave ? -2 : -1

	if (pathname === '/') {
		const file = await Deno.readFile('README.md')
		return new Response(parseMarkdown(file), {
			headers: {
				'content-type': getType('html'),
			},
		})

	}
	if (pathname.startsWith('/public')) {
		const file = await Deno.readFile(`.${pathname}`)
		const extension = pathname.split('.').slice(extensionPosition)

M server.lock.json => server.lock.json +7 -1
@@ 7,5 7,11 @@
  "https://deno.land/std@0.114.0/async/mux_async_iterator.ts": "62abff3af9ff619e8f2adc96fc70d4ca020fa48a50c23c13f12d02ed2b760dbe",
  "https://deno.land/std@0.114.0/async/pool.ts": "353ce4f91865da203a097aa6f33de8966340c91b6f4a055611c8c5d534afd12f",
  "https://deno.land/std@0.114.0/async/tee.ts": "3e9f2ef6b36e55188de16a667c702ace4ad0cf84e3720379160e062bf27348ad",
  "https://deno.land/std@0.114.0/http/server.ts": "46f616eac1ca0ea7b9fce97102d185a3d97ae7d7d3bbd635b74cefe05ed1cb37"
  "https://deno.land/std@0.114.0/http/server.ts": "46f616eac1ca0ea7b9fce97102d185a3d97ae7d7d3bbd635b74cefe05ed1cb37",
  "https://deno.land/x/brotli@v0.1.4/mod.ts": "d2e68b13f7fc7f7b3d6c27e554b02fbf75a651ab6e88aff056c81ef82646b4f2",
  "https://deno.land/x/brotli@v0.1.4/wasm.js": "09253260e66fbf04715971d0a4281a8dfe56ddba9e9b0c4dedfcf3aa6bf63ea6",
  "https://deno.land/x/lz4@v0.1.2/mod.ts": "4decfc1a3569d03fd1813bd39128b71c8f082850fe98ecfdde20025772916582",
  "https://deno.land/x/lz4@v0.1.2/wasm.js": "b9c65605327ba273f0c76a6dc596ec534d4cda0f0225d7a94ebc606782319e46",
  "https://deno.land/x/markdown_wasm@1.2.2/mod.ts": "f62bd338ce40827bf9e07ae8eaef578772e5e66376e5801c9dc1e2f4576b7962",
  "https://deno.land/x/markdown_wasm@1.2.2/wasm.js": "f15a6c9830d412e8aa6cac958bfca02ce4a6a083d3595c6512a59c2d75628576"
}
\ No newline at end of file