File tree Expand file tree Collapse file tree 6 files changed +45
-1
lines changed
Expand file tree Collapse file tree 6 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { ArticleCard } from '~/components/Post/ArticleCard/index.tsx';
33import { getPostsMetadata } from '~/lib/post.ts' ;
44import styles from './page.module.css' ;
55import type { FC } from 'react' ;
6+ import type { Metadata } from 'next' ;
67
78type CategoriesParams = {
89 categories ?: string [ ] ;
@@ -43,6 +44,17 @@ export const generateStaticParams = () => {
4344 return params ;
4445} ;
4546
47+ export const generateMetadata = async ( {
48+ params,
49+ } : PageProps ) : Promise < Metadata > => {
50+ const currentCategories = ( await params ) . categories || [ ] ;
51+
52+ return {
53+ title : `Articles${ currentCategories . length > 0 ? ` - ${ currentCategories . join ( ', ' ) } ` : '' } ` ,
54+ description : 'Here you can find all the articles available on the website.' ,
55+ } ;
56+ } ;
57+
4658const Page : FC < PageProps > = async ( { params } ) => {
4759 const currentCategories = ( await params ) . categories || [ ] ;
4860 const postsMetadata = await getPostsMetadata ( currentCategories [ 0 ] ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { getAllPosts } from '~/lib/post.ts';
44import { ArticleHeader } from '~/components/Post/ArticleHeader/index.tsx' ;
55import styles from './page.module.css' ;
66import type { FC } from 'react' ;
7+ import type { Metadata } from 'next' ;
78import type { PostFrontmatter } from '~/types/frontmatter' ;
89import '~/styles/markdown.css' ;
910
@@ -24,6 +25,24 @@ export async function generateStaticParams() {
2425 } ) ;
2526}
2627
28+ export async function generateMetadata ( {
29+ params,
30+ } : PageProps ) : Promise < Metadata > {
31+ const article = ( await params ) . article ;
32+ const slugs = [ 'post' , article ] ;
33+
34+ const mdxResult = await getContent < PostFrontmatter > ( slugs ) ;
35+
36+ if ( ! mdxResult ) notFound ( ) ;
37+
38+ const { frontmatter } = mdxResult ;
39+
40+ return {
41+ title : frontmatter . title ,
42+ description : frontmatter . description ,
43+ } ;
44+ }
45+
2746const Page : FC < PageProps > = async ( { params } ) => {
2847 const article = ( await params ) . article ;
2948 const slugs = [ 'post' , article ] ;
Original file line number Diff line number Diff line change @@ -3,8 +3,14 @@ import { GeistSans } from 'geist/font/sans';
33import { GeistMono } from 'geist/font/mono' ;
44import { Header } from '~/components/Sections/Header/index.tsx' ;
55import type { FC , PropsWithChildren } from 'react' ;
6+ import type { Metadata } from 'next' ;
67import '~/styles/globals.css' ;
78
9+ const metadata : Metadata = {
10+ title : 'Nodejs-Loaders' ,
11+ description : 'A collection of loaders for Node.js' ,
12+ } ;
13+
814const RootLayout : FC < PropsWithChildren > = ( { children } ) => (
915 < html lang = "en" >
1016 < body className = { classNames ( GeistSans . className , GeistMono . className ) } >
@@ -14,4 +20,5 @@ const RootLayout: FC<PropsWithChildren> = ({ children }) => (
1420 </ html >
1521) ;
1622
23+ export { metadata } ;
1724export default RootLayout ;
Original file line number Diff line number Diff line change 11import { Hero } from '~/components/Landing/Hero/index.tsx' ;
2- import { LatestArticleSection } from '~/components/Landing/LatestArticleSection /index.tsx' ;
2+ import { LatestArticleSection } from '~/components/Landing/LastestArticleSection /index.tsx' ;
33import type { FC } from 'react' ;
44
55const Page : FC = ( ) => (
You can’t perform that action at this time.
0 commit comments