Skip to content

Commit

Permalink
Added: Blog metadata added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arifulislam5577 committed Oct 23, 2024
1 parent 9a85207 commit 6b72cfd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
17 changes: 17 additions & 0 deletions app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Metadata } from 'next'
import { MDXRemote } from 'next-mdx-remote/rsc'
import { Suspense } from 'react'
import rehypePrettyCode from 'rehype-pretty-code'
Expand All @@ -11,6 +12,22 @@ export async function generateStaticParams() {
}))
}

export async function generateMetadata({ params }: { params: { slug: string } }): Promise<Metadata> {
const posts = getBlogs()
const post = posts.find((post) => post.slug === params.slug)

if (!post) {
return {
title: 'Keep React - Supercharge Your Web Development',
description:
'Explore our library of 40+ open-source React UI components and interactive elements, empowering you to create stunning web projects effortlessly.',
}
}
return {
title: post?.title,
}
}

const page = async ({ params }: { params: { slug: string } }) => {
const posts = getBlogs()
const post = posts.find((post) => post.slug === params.slug)
Expand Down
5 changes: 5 additions & 0 deletions app/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Metadata } from 'next'
import { getBlogs } from '~/utils/getMdxContent'
import Blog from '../components/Blog'

export const metadata: Metadata = {
title: 'Blog || Keep React',
}

const page = () => {
const blogs = getBlogs()
return (
Expand Down
1 change: 0 additions & 1 deletion app/src/utils/keepTw.ts

This file was deleted.

6 changes: 5 additions & 1 deletion utils/getMdxContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export const getBlogs = () => {

return {
slug: fileName.replace(/\.mdx$/, ''),
...data,
title: data?.title,
tag: data?.tag,
date: data?.date,
version: data?.version,
author: data?.author,
content,
}
})
Expand Down

0 comments on commit 6b72cfd

Please sign in to comment.