---
import { resolveShortLink } from "../utils/shortlink";

const { shortcode } = Astro.params;

if (!shortcode) {
    return Astro.redirect("/app");
}

const fullUrl = await resolveShortLink(shortcode);

if (fullUrl) {
    return Astro.redirect(fullUrl);
}
---

<!doctype html>
<html>
    <head>
        <title>Link Not Found</title>
    </head>
    <body>
        <h1>Link not found</h1>
        <p>This shortcode does not exist.</p>
        <a href="/app">Go to Dashboard Builder</a>
    </body>
</html>
