File tree 6 files changed +45
-1
lines changed
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';
3
3
import { getPostsMetadata } from '~/lib/post.ts' ;
4
4
import styles from './page.module.css' ;
5
5
import type { FC } from 'react' ;
6
+ import type { Metadata } from 'next' ;
6
7
7
8
type CategoriesParams = {
8
9
categories ?: string [ ] ;
@@ -43,6 +44,17 @@ export const generateStaticParams = () => {
43
44
return params ;
44
45
} ;
45
46
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
+
46
58
const Page : FC < PageProps > = async ( { params } ) => {
47
59
const currentCategories = ( await params ) . categories || [ ] ;
48
60
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';
4
4
import { ArticleHeader } from '~/components/Post/ArticleHeader/index.tsx' ;
5
5
import styles from './page.module.css' ;
6
6
import type { FC } from 'react' ;
7
+ import type { Metadata } from 'next' ;
7
8
import type { PostFrontmatter } from '~/types/frontmatter' ;
8
9
import '~/styles/markdown.css' ;
9
10
@@ -24,6 +25,24 @@ export async function generateStaticParams() {
24
25
} ) ;
25
26
}
26
27
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
+
27
46
const Page : FC < PageProps > = async ( { params } ) => {
28
47
const article = ( await params ) . article ;
29
48
const slugs = [ 'post' , article ] ;
Original file line number Diff line number Diff line change @@ -3,8 +3,14 @@ import { GeistSans } from 'geist/font/sans';
3
3
import { GeistMono } from 'geist/font/mono' ;
4
4
import { Header } from '~/components/Sections/Header/index.tsx' ;
5
5
import type { FC , PropsWithChildren } from 'react' ;
6
+ import type { Metadata } from 'next' ;
6
7
import '~/styles/globals.css' ;
7
8
9
+ const metadata : Metadata = {
10
+ title : 'Nodejs-Loaders' ,
11
+ description : 'A collection of loaders for Node.js' ,
12
+ } ;
13
+
8
14
const RootLayout : FC < PropsWithChildren > = ( { children } ) => (
9
15
< html lang = "en" >
10
16
< body className = { classNames ( GeistSans . className , GeistMono . className ) } >
@@ -14,4 +20,5 @@ const RootLayout: FC<PropsWithChildren> = ({ children }) => (
14
20
</ html >
15
21
) ;
16
22
23
+ export { metadata } ;
17
24
export default RootLayout ;
Original file line number Diff line number Diff line change 1
1
import { 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' ;
3
3
import type { FC } from 'react' ;
4
4
5
5
const Page : FC = ( ) => (
You can’t perform that action at this time.
0 commit comments