jointrashposs/components/docs/PrevNext.vue

48 lines
1.9 KiB
Vue
Raw Normal View History

2023-07-13 16:59:29 +02:00
<template>
<div class="flex flex-col lg:flex-row justify-between items-center">
<div class="order-2 mt-4 lg:mt-0 lg:order-1 w-full lg:w-2/5">
2023-09-29 13:30:13 +02:00
<GNuxtLink v-if="prev && prev._path.includes(currentDirectory)" :to="prev._path" class="rounded-lg transition-colors p-4 border dark:border-slate-700 hover:bg-slate-200 dark:hover:bg-slate-800 text-start flex justify-start items-center">
<div class="mr-3"><LeftIco /></div>
2023-07-13 16:59:29 +02:00
<div>
<div class="mb-1 text-sm">{{ $t('_docs._prevNext.prev') }}</div>
<div class="font-bold text-lg">{{ prev.title }}</div>
</div>
</GNuxtLink>
</div>
<div class="order-1 lg:order-2 w-full lg:w-2/5">
2023-09-29 13:30:13 +02:00
<GNuxtLink v-if="next && next._path.includes(currentDirectory)" :to="next._path" class="rounded-lg transition-colors p-4 border dark:border-slate-700 hover:bg-slate-200 dark:hover:bg-slate-800 text-end flex justify-end items-center">
2023-07-13 16:59:29 +02:00
<div>
<div class="mb-1 text-sm">{{ $t('_docs._prevNext.next') }}</div>
<div class="font-bold text-lg">{{ next.title }}</div>
</div>
<div class="ml-3"><RightIco /></div>
2023-07-13 16:59:29 +02:00
</GNuxtLink>
</div>
</div>
</template>
2023-07-11 19:19:32 +02:00
<script setup lang="ts">
import LeftIco from 'bi/arrow-left.svg';
import RightIco from 'bi/arrow-right.svg';
2023-07-13 16:59:29 +02:00
const { locale } = useI18n();
const route = useRoute();
const slugs = (route.params.slug as string[]).filter((v) => v !== '');
2023-07-11 19:19:32 +02:00
2023-07-17 18:43:55 +02:00
const props = withDefaults(defineProps<{
2023-07-13 16:59:29 +02:00
ignoreDirBasedNav?: boolean;
2023-07-17 18:43:55 +02:00
isDir?: boolean;
2023-07-13 16:59:29 +02:00
}>(), {
ignoreDirBasedNav: false,
2023-07-17 18:43:55 +02:00
isDir: false
2023-07-13 16:59:29 +02:00
});
2023-07-11 19:19:32 +02:00
2023-07-13 16:59:29 +02:00
const currentPath = `/${locale.value}/docs/${slugs.join('/')}`;
2023-09-24 14:03:39 +02:00
const currentDirectory = props.ignoreDirBasedNav ? `/${locale.value}/docs/` : props.isDir ? `/${locale.value}/docs/${slugs.join('/')}` : `/${locale.value}/docs/${slugs.slice(0, -1).join('/')}`;
2023-07-11 19:19:32 +02:00
2023-09-24 14:03:39 +02:00
const [prev, next] = await queryContent().where({ _partial: { $eq: false } }).findSurround(currentPath);
2023-07-11 19:19:32 +02:00
</script>
2023-07-13 16:59:29 +02:00
<style scoped>
2023-07-11 19:19:32 +02:00
2023-07-13 16:59:29 +02:00
</style>