elk/pages/[[server]]/tags/[tag].vue

45 lines
1.2 KiB
Vue
Raw Normal View History

<script setup lang="ts">
definePageMeta({
name: 'tag',
})
const params = useRoute().params
const tagName = computed(() => params.tag as string)
2022-11-23 00:08:36 +01:00
const { client } = useMasto()
const { data: tag, refresh } = await useAsyncData(() => client.value.v1.tags.$select(tagName.value).fetch(), { default: () => shallowRef() })
2022-11-28 21:46:04 +01:00
const paginator = client.value.v1.timelines.tag.$select(tagName.value).list()
const stream = useStreaming(client => client.hashtag.subscribe({ tag: tagName.value }))
2022-11-25 12:48:48 +01:00
if (tag.value) {
useHydratedHead({
title: () => `#${tag.value.name}`,
2022-11-28 21:46:04 +01:00
})
}
onReactivated(() => {
// Silently update data when reentering the page
// The user will see the previous content first, and any changes will be updated to the UI when the request is completed
refresh()
2022-11-25 12:48:48 +01:00
})
</script>
<template>
2022-11-26 13:58:10 +01:00
<MainContent back>
<template #title>
<bdi text-lg font-bold>#{{ tagName }}</bdi>
2022-11-28 21:46:04 +01:00
</template>
2023-01-05 17:48:20 +01:00
<template #actions>
<template v-if="typeof tag?.following === 'boolean'">
<TagActionButton :tag="tag" @change="refresh()" />
</template>
</template>
2022-11-24 07:42:26 +01:00
<slot>
2022-12-04 20:28:26 +01:00
<TimelinePaginator v-bind="{ paginator, stream }" context="public" />
</slot>
</MainContent>
</template>