1
1
---
2
- import { getCollection } from " astro:content" ;
2
+ import type { GetStaticPaths , Page } from " astro" ;
3
+ import { CollectionEntry , getCollection } from " astro:content" ;
3
4
import { css } from " styled-system/css" ;
4
5
import MDContainer from " ~/components/MDContainer.astro" ;
5
6
import ProjectCard from " ~/components/ProjectCard.astro" ;
6
7
import BaseLayout from " ~/layouts/BaseLayout.astro" ;
7
8
8
- const projects = await getCollection (" projects" );
9
+ export const getStaticPaths = (async ({ paginate }) => {
10
+ const projects = (await getCollection (" projects" )).sort (
11
+ (a , b ) => b .data .priority - a .data .priority ,
12
+ );
13
+
14
+ return paginate (projects , { pageSize: 4 });
15
+ }) satisfies GetStaticPaths ;
16
+
17
+ interface Props {
18
+ page: Page <CollectionEntry <" projects" >>;
19
+ }
20
+
21
+ const { page } = Astro .props ;
9
22
---
10
23
11
24
<BaseLayout title =" Projects | TheComputerM" >
@@ -15,11 +28,7 @@ const projects = await getCollection("projects");
15
28
Some of my most cherished and meticulously developed projects.
16
29
</p >
17
30
<hr />
18
- {
19
- projects
20
- .sort ((a , b ) => b .data .priority - a .data .priority )
21
- .map ((project ) => <ProjectCard project = { project } />)
22
- }
31
+ { page .data .map ((project ) => <ProjectCard project = { project } />)}
23
32
<hr />
24
33
<p >
25
34
See more of my work and other open-source contributions over on my
0 commit comments