This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import fjord from "@/fjord.config"; | ||
import { Metadata } from "next"; | ||
import { fetchPageBySlug } from "@/lib/data"; | ||
import CTA from "@/components/sections/cta"; | ||
import * as Craft from "@/components/craft/layout"; | ||
import { notFound } from "next/navigation"; | ||
|
||
export async function generateStaticParams() { | ||
const res = await fetch(`${fjord.wordpress_url}/wp-json/wp/v2/pages?_embed`, { | ||
next: { revalidate: 3600 }, | ||
}); | ||
|
||
const data: PageProps[] = await res.json(); | ||
|
||
return data.map((page) => ({ | ||
slug: page?.slug, | ||
})); | ||
} | ||
|
||
export default async function Page({ params }: { params: { slug: string } }) { | ||
const page: PageProps = await fetchPageBySlug(params?.slug); | ||
if (!page) { | ||
return notFound(); | ||
} | ||
|
||
const date = new Date(page.date); | ||
const author = page._embedded?.author?.[0] ?? null; | ||
|
||
const metadata: Metadata = { | ||
title: `${page.title.rendered} | ${fjord.site_name}`, | ||
description: page.excerpt?.rendered, | ||
}; | ||
|
||
return ( | ||
<Craft.Main> | ||
<Craft.Section> | ||
<Craft.Container> | ||
<h1 dangerouslySetInnerHTML={{ __html: page.title.rendered }}></h1> | ||
<div | ||
dangerouslySetInnerHTML={{ __html: page.content.rendered }} | ||
></div> | ||
</Craft.Container> | ||
</Craft.Section> | ||
|
||
<CTA /> | ||
</Craft.Main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters