local Common = require("common")
local Navbar = require("components.navbar")
local Footer = require("components.footer")
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 redirects = {
{ slug = "mrfinalboss", url = "https://jellingfish-games.itch.io/mr-final-boss" },
{ slug = "bumblingbuilders", url = "https://oroshibu.itch.io/bumbling-builders" }
}
local wrap_component = function(component)
return
end
local route = function(path, method, headers, body)
if method ~= 'GET' then
return 405, "Method not allowed"
end
if reluax.url_matches('/r/{slug}', path) then
local slug = reluax.url_extract('/r/{slug}', path).slug
local redirect = nil
for _, r in ipairs(redirects) do
if r.slug == slug then
redirect = r
break
end
end
if redirect then
local headers = {
["Location"] = redirect.url
}
local body = You are being redirected...
return 301, reluax.headers(body, headers)
end
elseif path == '/' then
return 200, wrap_component()
elseif path == '/projects' then
return 200, wrap_component()
elseif path == '/games' then
return 200, wrap_component()
elseif path == '/contact' then
return 200, wrap_component()
elseif path == '/blog' then
return 200, wrap_component()
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 =
return 200, article
end
end
return 404, NotFound()
end
return {
name = "duckonaut.dev",
route = route
}