web: fetch some content
This commit is contained in:
65
web/src/app/arrangementer/[slug]/page.tsx
Normal file
65
web/src/app/arrangementer/[slug]/page.tsx
Normal file
@ -0,0 +1,65 @@
|
||||
import { gql } from "@apollo/client";
|
||||
import { getClient } from "@/app/client";
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const query = gql(`
|
||||
{
|
||||
pages(contentType: "events.EventPage") {
|
||||
id
|
||||
slug
|
||||
}
|
||||
}
|
||||
`);
|
||||
const { data } = await getClient().query({
|
||||
query: query,
|
||||
});
|
||||
|
||||
return data.pages.map((page: any) => ({
|
||||
slug: page.slug,
|
||||
}));
|
||||
}
|
||||
|
||||
export default async function Page({ params }: { params: { slug: string } }) {
|
||||
const query = gql(`
|
||||
query ($slug: String!) {
|
||||
event: page(contentType: "events.EventPage", slug: $slug) {
|
||||
id
|
||||
slug
|
||||
title
|
||||
... on EventPage {
|
||||
body {
|
||||
id
|
||||
blockType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
// const response = await getClient()
|
||||
// .query({
|
||||
// query: query,
|
||||
// variables: { slug: params.slug },
|
||||
// })
|
||||
// .then()
|
||||
// .catch((e) => console.error(e.networkError.result.errors));
|
||||
|
||||
const { data } = await getClient().query({
|
||||
query: query,
|
||||
variables: { slug: params.slug },
|
||||
});
|
||||
|
||||
const { event } = data;
|
||||
|
||||
return (
|
||||
<main className="site-main" id="main">
|
||||
<section className="page-header textOnly">
|
||||
<h1>Et enkeltarrangement</h1>
|
||||
<p>!!</p>
|
||||
</section>
|
||||
<section className="page-content">
|
||||
<div key={event.id}>{event.title}</div>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
39
web/src/app/arrangementer/page.tsx
Normal file
39
web/src/app/arrangementer/page.tsx
Normal file
@ -0,0 +1,39 @@
|
||||
import { gql } from "@apollo/client";
|
||||
import { getClient } from "@/app/client";
|
||||
|
||||
export default async function Page() {
|
||||
const query = gql(`
|
||||
{
|
||||
pages(contentType: "events.EventPage") {
|
||||
id
|
||||
slug
|
||||
title
|
||||
... on EventPage {
|
||||
body {
|
||||
id
|
||||
blockType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
const { data } = await getClient().query({
|
||||
query: query,
|
||||
});
|
||||
|
||||
return (
|
||||
<main className="site-main" id="main">
|
||||
<section className="page-header textOnly">
|
||||
<h1>Arrangementer</h1>
|
||||
<p>woo</p>
|
||||
</section>
|
||||
{data.pages && (
|
||||
<section className="page-content">
|
||||
{data.pages.map((event) => (
|
||||
<div key={event.id}>{event.title}</div>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
11
web/src/app/client.ts
Normal file
11
web/src/app/client.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
|
||||
import { registerApolloClient } from "@apollo/experimental-nextjs-app-support/rsc";
|
||||
|
||||
export const { getClient } = registerApolloClient(() => {
|
||||
return new ApolloClient({
|
||||
cache: new InMemoryCache(),
|
||||
link: new HttpLink({
|
||||
uri: "https://cms.neuf.kult.444.no/api/graphql/",
|
||||
}),
|
||||
});
|
||||
});
|
@ -15,7 +15,7 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="no">
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
);
|
||||
|
Reference in New Issue
Block a user