First commit
This commit is contained in:
26
frontend/app/components/RecentlyViewed.vue
Normal file
26
frontend/app/components/RecentlyViewed.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ exclude?: string }>()
|
||||
|
||||
const { viewed } = useRecentlyViewed()
|
||||
const { t } = useI18n()
|
||||
|
||||
/* the list only exists in localStorage, so render it only after mount to
|
||||
keep the client's first render identical to the server's */
|
||||
const mounted = ref(false)
|
||||
onMounted(() => (mounted.value = true))
|
||||
|
||||
const others = computed(() =>
|
||||
mounted.value ? viewed.value.filter((v) => v.slug !== props.exclude) : []
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav v-if="others.length" class="recently-viewed" :aria-label="t('recent.aria')">
|
||||
<div class="rv-title">{{ t('recent.title') }}</div>
|
||||
<ul>
|
||||
<li v-for="v in others" :key="v.slug">
|
||||
<NuxtLink :to="`/wiki/${v.slug}`">{{ v.title }}</NuxtLink>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</template>
|
||||
Reference in New Issue
Block a user