From f9c72b3d8f047b107449a7c6db8a602fd5535438 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Fri, 14 Oct 2022 22:57:09 +0100 Subject: Initial commit --- Caddyfile | 6 +++ README.md | 21 +++++++++ content/landing.html | 1 + content/posts/1-hello-new-blog.html | 2 + content/posts/2-second-post.html | 1 + index.html | 87 +++++++++++++++++++++++++++++++++++++ routes.json | 14 ++++++ 7 files changed, 132 insertions(+) create mode 100644 Caddyfile create mode 100644 README.md create mode 100644 content/landing.html create mode 100644 content/posts/1-hello-new-blog.html create mode 100644 content/posts/2-second-post.html create mode 100644 index.html create mode 100644 routes.json diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..02ba6af --- /dev/null +++ b/Caddyfile @@ -0,0 +1,6 @@ +localhost { + encode gzip + root * . + try_files {path} /index.html + file_server +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..be7aeaf --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# spa + +Example SPA approach to a simple blog website. + +## prerequisites +- [caddy web server](https://caddywebserver.com) + +## run +launch with `caddy run` and open the browser to http://localhost + +## how it works + +caddy tries to load from files, and falls back to index.html by default if no file matches. + +[index.html](./index.html) has a plain page template and uses javascript to dynamically create navigation and load the content. + +[routes.json](./routes.json) file contains the metadata for website pages (currently just title and content location) + +content/* files are HTML content to be embedded in the page template. + +assets/* files are just plain files to be served direct. \ No newline at end of file diff --git a/content/landing.html b/content/landing.html new file mode 100644 index 0000000..95688d5 --- /dev/null +++ b/content/landing.html @@ -0,0 +1 @@ +Welcome to Martin's Blog! \ No newline at end of file diff --git a/content/posts/1-hello-new-blog.html b/content/posts/1-hello-new-blog.html new file mode 100644 index 0000000..8776c33 --- /dev/null +++ b/content/posts/1-hello-new-blog.html @@ -0,0 +1,2 @@ +Hello there, here's the content of the first post of my new blog + here's something blahh \ No newline at end of file diff --git a/content/posts/2-second-post.html b/content/posts/2-second-post.html new file mode 100644 index 0000000..8f83954 --- /dev/null +++ b/content/posts/2-second-post.html @@ -0,0 +1 @@ +And here's the second \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..eba968c --- /dev/null +++ b/index.html @@ -0,0 +1,87 @@ + + + + + + Martin's Blog! + + +

+ + + + \ No newline at end of file diff --git a/routes.json b/routes.json new file mode 100644 index 0000000..9b02008 --- /dev/null +++ b/routes.json @@ -0,0 +1,14 @@ +{ + "": { + "title": "Home", + "content": "/content/landing.html" + }, + "1-hello-new-blog": { + "title": "Hello New Blog", + "content": "/content/posts/1-hello-new-blog.html" + }, + "2-second-blog": { + "title": "Second Blog Post", + "content": "/content/posts/2-second-post.html" + } +} \ No newline at end of file -- cgit v1.2.3-ZIG