-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- includes fixes to eslint and rules
- Loading branch information
Showing
18 changed files
with
1,252 additions
and
1,012 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable @typescript-eslint/consistent-type-assertions */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
import { DefaultContentBody, Image } from 'dc-delivery-sdk-js'; | ||
import { notFound, ReadonlyURLSearchParams } from 'next/navigation'; | ||
import { Metadata } from 'next/types'; | ||
import React from 'react'; | ||
|
||
import { createAmplienceClient } from '~/amplience-client'; | ||
import { clientOptionsMapper } from '~/amplience-client/mappers/client-options-mapper'; | ||
import { getImageURL } from '~/components/amplience/image/image.utils'; | ||
import AmplienceContent from '~/components/amplience/wrapper/amplience-content'; | ||
|
||
export interface AmplienceBlogPageProps { | ||
searchParams: ReadonlyURLSearchParams; | ||
params: { slugs: string[] }; | ||
} | ||
|
||
export async function generateMetadata({ | ||
searchParams, | ||
params, | ||
}: AmplienceBlogPageProps): Promise<Metadata> { | ||
const amplienceClientOptions = clientOptionsMapper(searchParams); | ||
const amplienceClient = createAmplienceClient(amplienceClientOptions); | ||
const slug = params.slugs.join('/'); | ||
|
||
try { | ||
const blogPost = ( | ||
await amplienceClient.getContentItemByKey(slug) | ||
).toJSON() as DefaultContentBody; | ||
|
||
return { | ||
title: `Catalyst | ${blogPost.snippet?.title ?? ''} blog`, | ||
description: `${blogPost.snippet?.description}`, | ||
keywords: blogPost.snippet?.keywords as string[], | ||
openGraph: { | ||
images: getImageURL(blogPost.snippet?.image.image as Image), | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
site: '@amplience', | ||
creator: '@amplience', | ||
images: getImageURL(blogPost.snippet?.image.image as Image), | ||
}, | ||
}; | ||
} catch (e) { | ||
return notFound(); | ||
} | ||
} | ||
|
||
export default async function AmplienceBlogPage({ searchParams, params }: AmplienceBlogPageProps) { | ||
const amplienceClientOptions = clientOptionsMapper(searchParams); | ||
const amplienceClient = createAmplienceClient(amplienceClientOptions); | ||
const slug = params.slugs.join('/'); | ||
|
||
try { | ||
const blogPost = ( | ||
await amplienceClient.getContentItemByKey(slug) | ||
).toJSON() as DefaultContentBody; | ||
|
||
return <AmplienceContent content={blogPost} />; | ||
} catch (e) { | ||
return notFound(); | ||
} | ||
} | ||
|
||
export const runtime = 'edge'; |
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
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
Oops, something went wrong.