feat: /public/local timeline and timeline header (#3)

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
pull/4/head
patak 2022-11-15 14:50:41 +01:00 zatwierdzone przez GitHub
rodzic cf22ca25bf
commit a17d3276d3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 87 dodań i 14 usunięć

Wyświetl plik

@ -0,0 +1,13 @@
<template>
<div flex flex-col>
<div flex justify-between>
<div p3 flex gap-1>
<slot name="title" />
</div>
<div p3 flex>
<slot name="actions" />
</div>
</div>
<slot />
</div>
</template>

Wyświetl plik

@ -2,12 +2,16 @@
<div h-full of-hidden>
<main grid="~ lg:cols-[1fr_40rem_1fr]" h-full>
<div>
<NavTitle p4 />
<slot name="left">
<NavTitle p4 />
</slot>
</div>
<div h-full of-auto border="l r border">
<slot />
</div>
<div>Right</div>
<div>
<slot name="right" />
</div>
</main>
</div>
</template>

23
pages/home.vue 100644
Wyświetl plik

@ -0,0 +1,23 @@
<script setup lang="ts">
const token = useCookie('nuxtodon-token')
const router = useRouter()
if (!token.value)
router.replace('/public')
const masto = await useMasto()
const paginator = masto.timelines.getHomeIterable()
</script>
<template>
<MainContent>
<template #title>
<div i-ri:home-fill h-6 mr-1 /><span>Home</span>
</template>
<template #actions>
<div color-gray i-ri:equalizer-fill mr-1 h-6 />
</template>
<slot>
<TimelinePaginator :timelines="paginator" />
</slot>
</MainContent>
</template>

Wyświetl plik

@ -1,14 +1,14 @@
<script setup lang="ts">
const token = useCookie('nuxtodon-token')
const router = useRouter()
// TODO: move to middleware
if (!token.value)
router.replace('/public')
const masto = await useMasto()
const paginator = masto.timelines.getHomeIterable()
else
router.replace('/home')
</script>
<template>
<TimelinePaginator :paginator="paginator" />
<div />
</template>

Wyświetl plik

@ -1,8 +0,0 @@
<script setup lang="ts">
const masto = await useMasto()
const paginator = masto.timelines.getPublicIterable()
</script>
<template>
<TimelinePaginator :paginator="paginator" />
</template>

Wyświetl plik

@ -0,0 +1,18 @@
<script setup lang="ts">
const masto = await useMasto()
const { data: timelines } = await useAsyncData('timelines-public', () => masto.timelines.fetchPublic().then(r => r.value))
</script>
<template>
<MainContent>
<template #title>
<div i-ri:earth-fill h-6 mr-1 /><span>Federated Timeline</span>
</template>
<template #actions>
<div color-gray i-ri:equalizer-fill mr-1 h-6 />
</template>
<slot>
<TimelineList :timelines="timelines" />
</slot>
</MainContent>
</template>

Wyświetl plik

@ -0,0 +1,23 @@
<script setup lang="ts">
const token = useCookie('nuxtodon-token')
const router = useRouter()
if (!token.value)
router.replace('/public')
const masto = await useMasto()
const { data: timelines } = await useAsyncData('timelines-home', () => masto.timelines.fetchPublic({ local: true }).then(r => r.value))
</script>
<template>
<MainContent>
<template #title>
<div i-ri:group-fill h-6 mr-1 /><span>Local timeline</span>
</template>
<template #actions>
<div color-gray i-ri:equalizer-fill mr-1 h-6 />
</template>
<slot>
<TimelineList :timelines="timelines" />
</slot>
</MainContent>
</template>