---
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT

import { linkMap } from "../utils/utils";

type LinkType = keyof typeof linkMap;

interface Props {
    label?: string;
    type: LinkType;
}

const { label, type } = Astro.props as Props;
const displayLabel = label || type;

if (!(type in linkMap)) {
    throw new Error(
        `Invalid link type: ${type}. Maybe you forgot to add it to the linkMap?`,
    );
}

// The base is set in astro.config.mjs
const base = import.meta.env.BASE_URL;
const fullHref = `${base}${linkMap[type].href}`;
---

<a href={fullHref}><span>{displayLabel}</span></a>

