elk/pages/tags/[tag].vue

39 lines
1 KiB
Vue
Raw Normal View History

<script setup lang="ts">
const params = useRoute().params
2022-11-28 20:46:04 +00:00
const tagName = $(computedEager(() => params.tag as string))
2022-11-22 23:08:36 +00:00
2022-11-28 20:46:04 +00:00
const { data: tag, refresh } = $(await useAsyncData(() => useMasto().tags.fetch(tagName)))
const paginator = useMasto().timelines.getHashtagIterable(tagName)
const stream = await useMasto().stream.streamTagTimeline(tagName)
onBeforeUnmount(() => stream.disconnect())
2022-11-25 11:48:48 +00:00
2022-11-28 20:46:04 +00:00
if (tag) {
useHeadFixed({
2022-11-28 20:46:04 +00:00
title: () => `#${tag.name}`,
})
}
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 11:48:48 +00:00
})
</script>
<template>
2022-11-26 12:58:10 +00:00
<MainContent back>
<template #title>
2022-11-28 20:46:04 +00:00
<span text-lg font-bold>#{{ tagName }}</span>
</template>
<template v-if="typeof tag?.following === 'boolean'" #actions>
<TagActionButton :tag="tag" @change="refresh()" />
</template>
2022-11-24 06:42:26 +00:00
<slot>
<TimelinePaginator v-bind="{ paginator, stream }" />
</slot>
</MainContent>
</template>