1
+ import FeaturedShowcase from "@/components/FeaturedShowcase" ;
1
2
import InfoBox from "@/components/InfoBox" ;
2
3
import ExportedImage from "next-image-export-optimizer" ;
4
+ import { Post , posts , Recipe , recipes } from "@content" ;
5
+ import Card from "@/components/Card" ;
6
+ import CardGrid from "@/components/CardGrid" ;
7
+ import ArticleBlock from "@/components/ArticleBlock" ;
8
+ import { dateSort } from "@/utils/utils" ;
3
9
4
10
export default function Home ( ) {
11
+ const featuredRecipes = recipes
12
+ . filter ( ( recipe : Recipe ) => recipe . published && recipe . featured )
13
+ . sort ( dateSort )
14
+ . slice ( 0 , 4 ) ;
15
+
16
+ const featuredPosts = posts
17
+ . filter ( ( post : Post ) => post . published && post . featured )
18
+ . sort ( dateSort )
19
+ . slice ( 0 , 4 ) ;
20
+
21
+ const gridFormat : [ string , number , number , boolean ] [ ] = [
22
+ [ "l" , 1000 , 4 , true ] ,
23
+ [ "m" , 500 , 2 , true ] ,
24
+ [ "s" , 200 , 1 , true ] ,
25
+ ] ;
26
+ const margin : [ number , number ] = [ 15 , 15 ] ;
27
+ const containerPadding : [ number , number ] = [ 0 , 0 ] ;
28
+
5
29
return (
6
30
< >
7
31
< div className = "home-hero" >
@@ -10,24 +34,61 @@ export default function Home() {
10
34
src = "/home-hero.jpg"
11
35
alt = "Hero image"
12
36
fill = { true }
37
+ priority = { true }
13
38
/>
14
39
< h1 > Welcome to my website!</ h1 >
15
40
< div className = "subtitle" > Recipes, projects & more </ div >
16
41
</ div >
17
42
< div className = "home-page" >
18
- < InfoBox title = "Note" >
19
- < p >
20
- This is the new and improved version 2 of my website ! < br /> I
21
- finally made the switch from plain old HTML/CSS/JS to using Next.js.
22
- This has allowed me to easily make this website a lot easier to
23
- manage: I can now add recipes and posts in simple MDX format, and
24
- they are formatted and added everywhere automatically.
25
- </ p >
26
- < p >
27
- I{ "'" } m still adding some functionalities but I transferred most of
28
- the original content already, and more will come !
29
- </ p >
30
- </ InfoBox >
43
+ < div className = "force-article" >
44
+ < InfoBox title = "Note" >
45
+ < p >
46
+ This is the new and improved version 2 of my website ! < br /> I
47
+ finally made the switch from plain old HTML/CSS/JS to using
48
+ Next.js. This has allowed me to easily make this website a lot
49
+ easier to manage: I can now add recipes and posts in simple MDX
50
+ format, and they are formatted and added everywhere automatically.
51
+ </ p >
52
+ < p >
53
+ I{ "'" } m still adding some functionalities but I transferred most
54
+ of the original content already, and more will come !
55
+ </ p >
56
+ </ InfoBox >
57
+ </ div >
58
+ < FeaturedShowcase title = "Featured Recipes" >
59
+ < CardGrid
60
+ gridFormat = { gridFormat }
61
+ margin = { margin }
62
+ containerPadding = { containerPadding }
63
+ >
64
+ { featuredRecipes . map ( ( recipe ) => (
65
+ < Card
66
+ slug = { recipe . slug }
67
+ title = { recipe . name }
68
+ imageUrl = { recipe . coverImage . src }
69
+ key = { recipe . slug }
70
+ />
71
+ ) ) }
72
+ </ CardGrid >
73
+ </ FeaturedShowcase >
74
+ < FeaturedShowcase title = "Featured Posts" >
75
+ < CardGrid
76
+ gridFormat = { gridFormat }
77
+ margin = { margin }
78
+ containerPadding = { containerPadding }
79
+ >
80
+ { featuredPosts . map ( ( post : Post ) => (
81
+ < div className = "article-block-card" key = { post . slug } >
82
+ < ArticleBlock
83
+ article = { post }
84
+ disableTags = { true }
85
+ fillSpace = { true }
86
+ titleLevel = { 3 }
87
+ />
88
+ </ div >
89
+ ) ) }
90
+ </ CardGrid >
91
+ </ FeaturedShowcase >
31
92
</ div >
32
93
</ >
33
94
) ;
0 commit comments