add titles, description and images for seo
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Metadata, ResolvingMetadata } from "next";
|
||||
import { graphql } from "@/gql";
|
||||
import { VenueFragment, VenueRentalIndexFragment } from "@/gql/graphql";
|
||||
import { getClient } from "@/app/client";
|
||||
@@ -5,11 +6,29 @@ import { VenueList } from "@/components/venues/VenueList";
|
||||
import { PageHeader } from "@/components/general/PageHeader";
|
||||
import { BgPig } from "@/components/general/BgPig";
|
||||
import { PageContent } from "@/components/general/PageContent";
|
||||
import { getSeoMetadata } from "@/lib/seo";
|
||||
|
||||
const venueRentalIndexQuery = graphql(`
|
||||
query venueRentalIndex {
|
||||
index: venueRentalIndex {
|
||||
... on VenueRentalIndex {
|
||||
...VenueRentalIndex
|
||||
}
|
||||
}
|
||||
venues: pages(contentType: "venues.VenuePage", limit: 100) {
|
||||
... on VenuePage {
|
||||
...Venue
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
const VenueRentalIndexDefinition = graphql(`
|
||||
fragment VenueRentalIndex on VenueRentalIndex {
|
||||
... on VenueRentalIndex {
|
||||
title
|
||||
seoTitle
|
||||
searchDescription
|
||||
lead
|
||||
body {
|
||||
...Blocks
|
||||
@@ -18,21 +37,22 @@ const VenueRentalIndexDefinition = graphql(`
|
||||
}
|
||||
`);
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params }: { params: { url: string[] } },
|
||||
parent: ResolvingMetadata
|
||||
): Promise<Metadata | null> {
|
||||
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
||||
const index = (data?.index ?? []) as VenueRentalIndexFragment;
|
||||
|
||||
if (!index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const metadata = await getSeoMetadata(index, parent);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
export default async function Page() {
|
||||
const venueRentalIndexQuery = graphql(`
|
||||
query venueRentalIndex {
|
||||
index: venueRentalIndex {
|
||||
... on VenueRentalIndex {
|
||||
...VenueRentalIndex
|
||||
}
|
||||
}
|
||||
venues: pages(contentType: "venues.VenuePage", limit: 100) {
|
||||
... on VenuePage {
|
||||
...Venue
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
const { data, error } = await getClient().query(venueRentalIndexQuery, {});
|
||||
const index = (data?.index ?? []) as VenueRentalIndexFragment;
|
||||
const venues = (data?.venues ?? []) as VenueFragment[];
|
||||
|
Reference in New Issue
Block a user