diff options
| author | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-14 16:21:57 +0100 |
|---|---|---|
| committer | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-14 16:21:57 +0100 |
| commit | fe7254f7a7b7c8b95824f2d6ce2ee56709ba019d (patch) | |
| tree | 325d04c74c54d1b90b483a96be8c6b689f34137c /luax/reluax.luax | |
| parent | 6b068ccd9156de8515203d0000c3a2a8ecb9c5fb (diff) | |
luax: stuff
Diffstat (limited to 'luax/reluax.luax')
| -rw-r--r-- | luax/reluax.luax | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/luax/reluax.luax b/luax/reluax.luax index ebe1f21..b078ce8 100644 --- a/luax/reluax.luax +++ b/luax/reluax.luax @@ -6,9 +6,12 @@ local Home = require("pages.home") local Projects = require("pages.projects") local Games = require("pages.games") local Contact = require("pages.contact") -local Article = require("pages.article") +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) @@ -32,17 +35,29 @@ local function route(path) return 200, wrap_component(<Games />) elseif path == '/contact' then return 200, wrap_component(<Contact />) - elseif reluax.url_matches('/article/{title}', path) then - local title = reluax.url_extract('/article/{title}', path).title - local article = <Common><Article title={title} /></Common> + 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 = wrap_component(<Blogpost post={post} />) return 200, article + end end return 404, NotFound() end return { - name = "hello-world", + name = "duckonaut.dev", route = route } |
