diff options
author | Martin Ashby <martin@ashbysoft.com> | 2022-10-15 22:36:52 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2022-10-15 22:36:52 +0100 |
commit | 297d38b69efaa54f5585b806e7934375d2df9765 (patch) | |
tree | 76c11158f1d6f2e2f2a8d948b6e6360e75884136 | |
download | blogsite2-main.tar.gz blogsite2-main.tar.bz2 blogsite2-main.tar.xz blogsite2-main.zip |
Initial commitmain
-rw-r--r-- | Caddyfile | 9 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | content/index.html | 15 | ||||
-rw-r--r-- | content/markdown/1-hello-blog.md | 14 | ||||
-rw-r--r-- | include/head.html | 26 | ||||
-rw-r--r-- | index.html | 17 | ||||
-rw-r--r-- | index.xml | 0 |
7 files changed, 85 insertions, 0 deletions
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}} +<!doctype html> +<html> +<head> + {{ include "/include/head.html" }} +</head> +<body> + <article>{{ markdown $markdownFile.Body }}</article> +</body> +</html>
\ 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 @@ +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<style> + /* CSS taken from https://perfectmotherfuckingwebsite.com/ */ + body{ + max-width:650px; + margin:40px auto; + padding:0 10px; + font:18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + color:#444 + } + h1,h2,h3{ + line-height:1.2 + } + @media (prefers-color-scheme: dark){ + body{ + color:#c9d1d9; + background:#0d1117 + } + a:link{ + color:#58a6ff + } + a:visited{ + color:#8e96f0 + } + } +</style> diff --git a/index.html b/index.html new file mode 100644 index 0000000..7ac5dd1 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ +<!doctype HTML> +<html> +<head> + {{ include "/include/head.html" }} +</head> +<body> + <nav> + <ol> + <li><a href="/">Home</a></li> + <li><a href="/content/1-hello-blog">Hello, Blog</a></li> + </ol> + </nav> + <h1>Blogsite</h1> + <p>Welcome to martin's next blogsite PoC</p> + <p>Read my <a href="/content/1-hello-blog">content</a></p> +</body> +</html>
\ No newline at end of file diff --git a/index.xml b/index.xml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/index.xml |