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

46 lines
1.2 KiB
Vue
Raw Normal View History

<script setup lang="ts">
definePageMeta({
name: 'tag',
})
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
const masto = useMasto()
2023-01-08 06:21:09 +00:00
const { data: tag, refresh } = $(await useAsyncData(() => masto.v1.tags.fetch(tagName), { watch: [isMastoInitialised], immediate: isMastoInitialised.value }))
2022-11-28 20:46:04 +00:00
2023-01-08 06:21:09 +00:00
const paginator = masto.v1.timelines.listHashtag(tagName)
const stream = masto.v1.stream.streamTagTimeline(tagName)
onBeforeUnmount(() => stream.then(s => s.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>
2023-01-05 16:48:20 +00:00
<template #actions>
<template v-if="typeof tag?.following === 'boolean'">
<TagActionButton :tag="tag" @change="refresh()" />
</template>
</template>
2022-11-24 06:42:26 +00:00
<slot>
2022-12-04 19:28:26 +00:00
<TimelinePaginator v-bind="{ paginator, stream }" context="public" />
</slot>
</MainContent>
</template>