45 lines
1.0 KiB
Vue
45 lines
1.0 KiB
Vue
<!-- 上一篇 下一篇 -->
|
||
<script setup lang="ts">
|
||
import {detail} from "~/utils/common";
|
||
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
|
||
import {getNext, getPrevious} from "~/api/cms/cmsArticle";
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
articleId?: number;
|
||
}>(),
|
||
{}
|
||
);
|
||
|
||
const i18n = useI18n();
|
||
const previousArticle = ref<CmsArticle>();
|
||
const nextArticle = ref<CmsArticle>();
|
||
|
||
// 上一篇
|
||
previousArticle.value = await getPrevious({
|
||
articleId: props.articleId,
|
||
lang: i18n.locale.value
|
||
})
|
||
// 下一篇
|
||
nextArticle.value = await getNext({
|
||
articleId: props.articleId,
|
||
lang: i18n.locale.value
|
||
})
|
||
|
||
</script>
|
||
|
||
<template>
|
||
<div class="page flex flex-col">
|
||
<span class="text-left">
|
||
{{ $t('previous') }}:<a :href="detail(previousArticle)">{{ previousArticle?.title }}</a>
|
||
</span>
|
||
<span class="text-left">
|
||
{{ $t('next') }}:<a :href="detail(nextArticle)">{{ nextArticle?.title }}</a>
|
||
</span>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped lang="scss">
|
||
|
||
</style>
|