web: optimize news fetching
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
import { Metadata, ResolvingMetadata } from "next";
|
||||
import { getClient } from "@/app/client";
|
||||
import {
|
||||
NewsIndexView,
|
||||
loadNewsIndexProps,
|
||||
} from "@/components/news/NewsIndexView";
|
||||
import { NewsIndexFragment } from "@/gql/graphql";
|
||||
import { newsIndexMetadataQuery } from "@/lib/news";
|
||||
import { getSeoMetadata } from "@/lib/seo";
|
||||
|
||||
export async function generateMetadata(
|
||||
_: unknown,
|
||||
parent: ResolvingMetadata
|
||||
): Promise<Metadata | null> {
|
||||
const { index } = await loadNewsIndexProps();
|
||||
return getSeoMetadata(index, parent);
|
||||
const { data, error } = await getClient().query(newsIndexMetadataQuery, {});
|
||||
if (error) throw new Error(error.message);
|
||||
if (!data?.index) return null;
|
||||
return getSeoMetadata(data.index as NewsIndexFragment, parent);
|
||||
}
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
Reference in New Issue
Block a user