From c8b2ae0f079b1e43b250772f416cbe8d93c1a776 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 28 Dec 2023 23:11:47 +0900 Subject: [PATCH] create caddy-md --- caddy-md/Caddyfile | 5 +++++ caddy-md/compose.yml | 8 ++++++++ caddy-md/srv/a.md | 1 + caddy-md/srv/index.html | 15 +++++++++++++++ caddy-md/srv/index.md | 9 +++++++++ 5 files changed, 38 insertions(+) create mode 100644 caddy-md/Caddyfile create mode 100644 caddy-md/compose.yml create mode 100644 caddy-md/srv/a.md create mode 100644 caddy-md/srv/index.html create mode 100644 caddy-md/srv/index.md diff --git a/caddy-md/Caddyfile b/caddy-md/Caddyfile new file mode 100644 index 0000000..6f254dc --- /dev/null +++ b/caddy-md/Caddyfile @@ -0,0 +1,5 @@ +:8080 { + file_server + templates + try_files {path} / +} diff --git a/caddy-md/compose.yml b/caddy-md/compose.yml new file mode 100644 index 0000000..ff4353a --- /dev/null +++ b/caddy-md/compose.yml @@ -0,0 +1,8 @@ +services: + caddy: + image: caddy + ports: + - 8080:8080 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - ./srv:/srv diff --git a/caddy-md/srv/a.md b/caddy-md/srv/a.md new file mode 100644 index 0000000..06b863f --- /dev/null +++ b/caddy-md/srv/a.md @@ -0,0 +1 @@ +# あ diff --git a/caddy-md/srv/index.html b/caddy-md/srv/index.html new file mode 100644 index 0000000..b631e39 --- /dev/null +++ b/caddy-md/srv/index.html @@ -0,0 +1,15 @@ + +{{- $path := .OriginalReq.URL.Path}} +{{- if hasSuffix "/" $path}}{{$path = print $path "index"}}{{end}} +{{- $path = print $path ".md"}} +{{- if not (fileExists $path)}}{{httpError 404}}{{end}} +{{- $markdown := (include $path | splitFrontMatter)}} +{{- $title := default (trimSuffix ".md" (base $path)) $markdown.Meta.title}} + + + +{{$title}} + +{{markdown $markdown.Body | trim}} + + diff --git a/caddy-md/srv/index.md b/caddy-md/srv/index.md new file mode 100644 index 0000000..4e2ccfb --- /dev/null +++ b/caddy-md/srv/index.md @@ -0,0 +1,9 @@ +--- +title: トップ +--- + +# トップページ + +こんにちは、世界 + +- [a](a)