mirror of
https://github.com/UiO-Gaming/uiogaming.no.git
synced 2026-11-05 13:56:47 +01:00
fetch board member data on data change
This commit is contained in:
1 parent
d44fbfa9d7
commit
13463d4eeb
3 files changed
+43
-26
No files matched your search
@@ -26,10 +26,12 @@ export async function POST(request: NextRequest) {
|
||||
if (slug?.current) {
|
||||
revalidateTag(`event-${slug.current}`, "max")
|
||||
}
|
||||
} else if (_type === "author") {
|
||||
revalidateTag("authors", "max")
|
||||
// Blog posts show the author's name and image
|
||||
revalidateTag("blog-posts", "max")
|
||||
}
|
||||
|
||||
revalidateTag("home", "max")
|
||||
|
||||
return NextResponse.json({
|
||||
revalidated: true,
|
||||
now: Date.now(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { urlFor } from "@/lib/imageUrlBuilder"
|
||||
import { sanityClient } from "@/lib/sanity"
|
||||
import { getBoardMembers } from "@/lib/sanity"
|
||||
|
||||
import { getLocale, getTranslations } from "next-intl/server"
|
||||
import Image from "next/image"
|
||||
@@ -31,29 +31,7 @@ const BoardMembers = async () => {
|
||||
const t = await getTranslations("boardMembers")
|
||||
const locale = (await getLocale()) as "no" | "en"
|
||||
|
||||
const query = `
|
||||
*[_type == "author" && boardMember == true] | order(orderRank asc) {
|
||||
_id,
|
||||
boardMember,
|
||||
contactInfo,
|
||||
name,
|
||||
role {
|
||||
no,
|
||||
en
|
||||
},
|
||||
image {
|
||||
asset->{
|
||||
_id,
|
||||
url
|
||||
}
|
||||
},
|
||||
bio {
|
||||
no,
|
||||
en
|
||||
}
|
||||
}
|
||||
`
|
||||
const data: BoardMember[] = await sanityClient.fetch(query)
|
||||
const data: BoardMember[] = await getBoardMembers()
|
||||
|
||||
return (
|
||||
<section id="board-members">
|
||||
|
||||
@@ -95,3 +95,40 @@ export async function getAllEvents() {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export async function getBoardMembers() {
|
||||
const query = `
|
||||
*[_type == "author" && boardMember == true] | order(orderRank asc) {
|
||||
_id,
|
||||
boardMember,
|
||||
contactInfo,
|
||||
name,
|
||||
role {
|
||||
no,
|
||||
en
|
||||
},
|
||||
image {
|
||||
asset->{
|
||||
_id,
|
||||
url
|
||||
}
|
||||
},
|
||||
bio {
|
||||
no,
|
||||
en
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
return sanityClient.fetch(
|
||||
query,
|
||||
{},
|
||||
{
|
||||
cache: "force-cache",
|
||||
next: {
|
||||
tags: ["authors"],
|
||||
revalidate: 3600, // 1 hour
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user