<template>
    <div class="prose p-0 max-w-none">
        <ContentRenderer :value="targetData" />
    </div>
</template>

<script setup lang="ts">
const route = useRoute();
let targetData = ref();
let target = '';

const { path } = useRoute();

if (route.params.target instanceof Array) {
    switch (route.params.target[0]) {
        case 'kss':
        case 'api_doc':
        case 'bill':
        case 'guide':
        // case 'privacy':
        // case 'stipulation':
        case 'contract':

        case 'certification':
        case 'manual':
            target = route.params.target[0];

            break;
    }

    if (target != '') {
        const { data } = await useAsyncData(`content-${path}`, () => {
            return queryContent().where({ _path: path }).findOne();
        });
        /*
        const { data } = await useAsyncData('home', () =>
            queryContent('/doc/' + target).findOne()
        );
        */
        targetData = data;
    } else {
        throwError('$404');
    }
} else {
    throwError('$404');
}
</script>
