aboutsummaryrefslogtreecommitdiff
path: root/reluax.luax
diff options
context:
space:
mode:
authorStanisław Zagórowski <hasohasacz@gmail.com>2024-01-15 14:21:34 +0100
committerStanisław Zagórowski <hasohasacz@gmail.com>2024-01-15 14:21:34 +0100
commit63ea67e4c3c8caa2cf0dc6d7c940981bd40b3974 (patch)
tree9900794e80bd4413ceb4dad72cdfc3eeaf0d6c9b /reluax.luax
parentd5c0555775ac835f75246a17b5e6f3ddc353d82b (diff)
all: move out from luax/
Diffstat (limited to 'reluax.luax')
-rw-r--r--reluax.luax72
1 files changed, 72 insertions, 0 deletions
diff --git a/reluax.luax b/reluax.luax
new file mode 100644
index 0000000..1cfc04c
--- /dev/null
+++ b/reluax.luax
@@ -0,0 +1,72 @@
+local Common = require("common")
+local Navbar = require("components.navbar")
+local AnimatedBg = require("components.animated_bg")
+
+local Home = require("pages.home")
+local Projects = require("pages.projects")
+local Games = require("pages.games")
+local Contact = require("pages.contact")
+local Blogpost = require("pages.blogpost")
+local Blog = require("pages.blog")
+local NotFound = require("not_found")
+
+local blogposts = require("blog.posts")
+
+math.randomseed(os.time())
+
+local function wrap_component(component)
+ return
+ <Common>
+ <Navbar />
+ <div class="back-shadows"></div>
+ <div id="app-main">
+ {$ component $}
+ <AnimatedBg />
+ </div>
+ </Common>
+end
+
+local function route(path)
+ if path == '/' then
+ return 200, wrap_component(<Home />)
+ elseif path == '/projects' then
+ return 200, wrap_component(<Projects />)
+ elseif path == '/games' then
+ return 200, wrap_component(<Games />)
+ elseif path == '/contact' then
+ return 200, wrap_component(<Contact />)
+ elseif path == '/blog' then
+ return 200, wrap_component(<Blog />)
+ elseif reluax.url_matches('/blog/{slug}', path) then
+ local slug = reluax.url_extract('/blog/{slug}', path).slug
+ -- blogposts is a list of blogposts, with the slug a property of each
+ local post = nil
+ for _, p in ipairs(blogposts) do
+ if p.slug == slug then
+ post = p
+ break
+ end
+ end
+ if post then
+ local article =
+ <Common title={post.title} description={post.description}>
+ <Navbar />
+ <div class="back-shadows"></div>
+ <div id="app-main">
+ <Blogpost post={post} />
+ <AnimatedBg />
+ </div>
+ </Common>
+
+ return 200, article
+ end
+ end
+
+ return 404, NotFound()
+end
+
+return {
+ name = "duckonaut.dev",
+ route = route
+}
+