-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata generation and refactor LearningHubPost logic (#22)
* Add metadata generation and refactor LearningHubPost logic This update introduces metadata generation for LearningHubPost pages, enhancing SEO and social media sharing. It also refactors the component architecture by extracting reusable functions for fetching post data, improving code maintainability and readability. Localization for metadata fields is integrated using `next-intl`. * Update sorting logic and query parameter structure Revised `SortOptions` to use `"[key]=value"` format and adjusted filters accordingly. Introduced default sorting to 'Newest' and refined query construction for better compatibility. Added debug logs and ensured safer handling in rendering conditional components.
- Loading branch information
Showing
6 changed files
with
110 additions
and
29 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 |
---|---|---|
@@ -1,9 +1,42 @@ | ||
import LearningHubPost from '@/components/LearningHubPost' | ||
import { getTranslations } from 'next-intl/server' | ||
|
||
import LearningHubPost, { | ||
getPostId, | ||
LearningHubPostPageProps, | ||
resolvingPost, | ||
} from '@/components/LearningHubPost' | ||
import { config } from '@/config' | ||
|
||
export async function generateMetadata({ params }: LearningHubPostPageProps) { | ||
const t = await getTranslations({ locale: params.locale, namespace: '' }) | ||
|
||
const post = await resolvingPost(params.id) | ||
|
||
return { | ||
metadataBase: new URL('https://rarimo.com/'), | ||
title: post.attributes.title, | ||
description: post.attributes.shortDescription, | ||
|
||
openGraph: { | ||
type: 'website', | ||
siteName: t('metadata.openGraph.siteName'), | ||
title: post.attributes.title, | ||
description: post.attributes.shortDescription, | ||
url: `${config.learningHubApiUrl}/posts/${getPostId(params.id)}`, | ||
images: post.attributes.coverImage, | ||
}, | ||
|
||
twitter: { | ||
site: t('metadata.twitter.site'), | ||
title: post.attributes.title, | ||
description: post.attributes.shortDescription, | ||
images: post.attributes.coverImage, | ||
}, | ||
} | ||
} | ||
|
||
export default async function LearningHubPostPage({ | ||
params, | ||
}: { | ||
params: { id: string } | ||
}) { | ||
}: LearningHubPostPageProps) { | ||
return <LearningHubPost params={params} /> | ||
} |
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