/
TheTalks.server.vue
156 lines (150 loc) · 4.46 KB
/
TheTalks.server.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<script setup lang="ts">
interface Talk {
slug: string
group?: string
description?: string
title: string
source: string
tags: string
link: string
date: string
type: 'talk' | 'podcast' | 'meetup' | 'talk' | 'conference' | 'mini-workshop'
video?: string
release?: string
repo?: string
demo?: string
}
// if (import.meta.prerender && import.meta.server) {
// for (const conference of upcomingConferences) {
// await useStorage().setItem(conference.image, conference.link)
// appendHeader(
// useRequestEvent(),
// 'x-nitro-prerender',
// '/thumbnail/' + conference.image
// )
// }
// }
const { data: groups } = await useAsyncData(
() =>
((import.meta.server || import.meta.dev) as true)
&& import('../data/talks.json').then(r => r.default as any as Talk[]),
{
transform: talks => {
const groupedTalks: Record<string, Talk[]> = {}
for (const talk of talks) {
const slug = talk.group || talk.slug
groupedTalks[slug] ||= []
groupedTalks[slug].push(talk)
}
for (const group in groupedTalks) {
groupedTalks[group].sort(
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime(),
)
}
const groups = Object.entries(groupedTalks).sort(
([_s1, [a]], [_s2, [b]]) => {
return new Date(b.date).getTime() - new Date(a.date).getTime()
},
)
return groups
},
},
)
</script>
<template>
<section class="flex flex-row flex-wrap gap-4 max-w-[37.50rem]">
<section
v-for="[slug, talks] of groups"
:key="slug"
class="mb-2 w-full relative flex flex-col justify-end min-h-12 transition-all border-1 border-solid border-transparent after:text-transparent flex-[100%]"
>
<div class="flex flex-row items-center gap-2 text-xl">
{{ talks[0].title }}
</div>
<div
v-if="talks[0].description"
class="text-base mb-1"
>
{{ talks[0].description }}
</div>
<article
v-for="talk of talks"
:key="talk.link"
:class="{ 'opacity-60': !talk.video && !talk.link && !talk.release && !talk.demo && !talk.repo }"
:alt="talk.title"
>
<header class="flex flex-row mt-1">
<dl
v-if="talk.date"
class="flex flex-row items-center gap-4 leading-normal text-sm w-full"
>
<dt class="sr-only">
Date
</dt>
<dd class="md:min-w-24 uppercase opacity-60 text-xs flex-shrink-0">
<NuxtTime
:datetime="talk.date"
day="numeric"
month="short"
year="numeric"
/>
</dd>
<dt
v-if="talk.source"
class="sr-only"
>
Where
</dt>
<dd
v-if="talk.source"
class="text-ellipsis line-clamp-1"
>
{{ talk.source }}
</dd>
</dl>
<ExpandableTray
v-if="talk.video || talk.link || talk.release || talk.demo || talk.repo"
class="ml-auto flex items-start"
>
<NuxtLink
v-if="talk.video || talk.link"
:href="talk.video || talk.link"
class="text-xs items-center"
>
<span
v-if="talk.type === 'podcast' || talk.video"
:class="talk.video ? 'i-ri:play-line' : 'i-ri:broadcast-line'"
class="h-4 w-4 flex-shrink-0"
/>
{{ talk.video ? `watch` : `listen` }}
</NuxtLink>
<NuxtLink
v-if="talk.release"
class="text-xs items-center"
:to="`/slides/${talk.release}.pdf`"
data-external
>
<span class="i-ri:presentation-fill" /> slides
</NuxtLink>
<NuxtLink
v-if="talk.demo"
class="text-xs items-center"
:to="talk.demo"
data-external
>
<span class="i-tabler:sparkles" /> demo
</NuxtLink>
<NuxtLink
v-if="talk.repo"
class="text-xs items-center"
:to="talk.repo"
data-external
>
<span class="i-ri:github-fill" /> repo
</NuxtLink>
</ExpandableTray>
</header>
</article>
</section>
</section>
</template>