<script setup lang="ts">
import { getMetadata } from "@/api/meta";
import type { Metadata } from "@/types";
import { onBeforeMount, ref } from "vue";
import LangInput from "@/components/LangInput.vue";

const metadata = ref<Metadata | null>(null);

function fetchMetadata() {
    void getMetadata().then((data) => {
        metadata.value = data;
        setTimeout(fetchMetadata, 600000);
    });
}

onBeforeMount(fetchMetadata);
</script>

<template>
    <footer
        class="footer sm:footer-horizontal footer-center bg-base-300 text-base-content p-2"
    >
        <aside>
            <p>
                <lang-input /> - 2026 -
                <a
                    href="https://git.klemek.fr/klemek/tout-doux"
                    class="underline"
                >
                    klemek
                </a>
                <span v-if="metadata">- {{ $t("metadata", metadata) }}</span>
            </p>
        </aside>
    </footer>
</template>
