From 297d38b69efaa54f5585b806e7934375d2df9765 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Sat, 15 Oct 2022 22:36:52 +0100 Subject: Initial commit --- Caddyfile | 9 +++++++++ README.md | 4 ++++ content/index.html | 15 +++++++++++++++ content/markdown/1-hello-blog.md | 14 ++++++++++++++ include/head.html | 26 ++++++++++++++++++++++++++ index.html | 17 +++++++++++++++++ index.xml | 0 7 files changed, 85 insertions(+) create mode 100644 Caddyfile create mode 100644 README.md create mode 100644 content/index.html create mode 100644 content/markdown/1-hello-blog.md create mode 100644 include/head.html create mode 100644 index.html create mode 100644 index.xml diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..cd50616 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,9 @@ +localhost { + root * . + encode gzip + file_server + templates + try_files {path}.html {path} + redir /content content/ + rewrite /content/* content/index.html +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..adebed4 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# blogsite2 + +Another alternative approach to blogsite, use Caddy [templates](https://caddyserver.com/docs/caddyfile/directives/templates). + diff --git a/content/index.html b/content/index.html new file mode 100644 index 0000000..26355a3 --- /dev/null +++ b/content/index.html @@ -0,0 +1,15 @@ +{{$pathParts := splitList "/" .OriginalReq.URL.Path}} +{{$markdownFilename := default "index" (slice $pathParts 2 | join "/")}} +{{$markdownFilePath := printf "/content/markdown/%s.md" $markdownFilename}} +{{if not (fileExists $markdownFilePath)}}{{httpError 404}}{{end}} +{{$markdownFile := (include $markdownFilePath | splitFrontMatter)}} +{{$title := default $markdownFilename $markdownFile.Meta.title}} + + + + {{ include "/include/head.html" }} + + +
{{ markdown $markdownFile.Body }}
+ + \ No newline at end of file diff --git a/content/markdown/1-hello-blog.md b/content/markdown/1-hello-blog.md new file mode 100644 index 0000000..4cf5986 --- /dev/null +++ b/content/markdown/1-hello-blog.md @@ -0,0 +1,14 @@ +--- +title: Hello New Blog +--- +Hi, here's a new *markdown* _formatted_ + +## blog post! + +Here's a table: + +|-----------------| +| foo | bar | baz | +|-----|-----|-----| +| val | smt | 123 | +|-----------------| \ No newline at end of file diff --git a/include/head.html b/include/head.html new file mode 100644 index 0000000..b3d945d --- /dev/null +++ b/include/head.html @@ -0,0 +1,26 @@ + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..7ac5dd1 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + {{ include "/include/head.html" }} + + + +

Blogsite

+

Welcome to martin's next blogsite PoC

+

Read my content

+ + \ No newline at end of file diff --git a/index.xml b/index.xml new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-ZIG