-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathAnnouncement.tsx
36 lines (32 loc) · 1 KB
/
Announcement.tsx
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
import { fetchSanityLive } from '@/sanity/lib/fetch'
import { groq } from 'next-sanity'
import { linkQuery } from '@/sanity/lib/queries'
import Scheduler from './Scheduler'
import { PortableText } from 'next-sanity'
import CTA from '@/ui/CTA'
export default async function Announcement() {
const announcements = await fetchSanityLive<
(Sanity.Announcement & Sanity.Module)[]
>({
query: groq`*[_type == 'site'][0].announcements[]->{
...,
cta{ ${linkQuery} },
}`,
tag: 'announcements',
})
if (!announcements) return null
return (
<>
{announcements?.map(({ start, end, content, cta, _id }) => (
<Scheduler start={start} end={end} key={_id}>
<aside className="flex items-center justify-center gap-x-4 text-balance bg-accent p-2 text-center text-canvas max-md:text-sm md:gap-x-6">
<div className="anim-fade-to-r [&_a]:link">
<PortableText value={content} />
</div>
<CTA className="link anim-fade-to-l shrink" link={cta} />
</aside>
</Scheduler>
))}
</>
)
}