From 35d76e1b92692398ed61caef819b678477204989 Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Mon, 29 Jan 2024 17:08:34 +0100 Subject: site: add redirects, remove annoying CSS --- reluax.luax | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'reluax.luax') diff --git a/reluax.luax b/reluax.luax index cb45ae6..034d408 100644 --- a/reluax.luax +++ b/reluax.luax @@ -15,7 +15,12 @@ local blogposts = require("blog.posts") math.randomseed(os.time()) -local function wrap_component(component) +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 @@ -28,8 +33,28 @@ local function wrap_component(component) end -local function route(path) - if path == '/' then +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() -- cgit v1.3.1