@@ -24,9 +24,17 @@ const { title, description, pubDate, tags } = entry.data;
2424const { Content } = await render (entry );
2525
2626// Get all entries in current category for prev/next arrow navigation
27- const projects = (await getCollection (' work' ))
28- .filter ((project ) => project .data .category === entry .data .category )
29- .sort ((a , b ) => b .data .pubDate .valueOf () - a .data .pubDate .valueOf ());
27+ const projects = await getCollection (' work' );
28+
29+ projects .sort ((a , b ) => {
30+ // ascending by order
31+ if (a .data .order || b .data .order ) {
32+ return (a .data .order || projects .length ) - (b .data .order || projects .length );
33+ }
34+
35+ // descending by published date
36+ return b .data .pubDate .valueOf () - a .data .pubDate .valueOf ();
37+ });
3038
3139const currentIndex = projects .findIndex (({ id }) => id === entry .id );
3240const prevEntry = projects [(currentIndex - 1 + projects .length ) % projects .length ];
@@ -44,7 +52,8 @@ const nextEntry = projects[(currentIndex + 1) % projects.length];
4452 <a
4553 href = { ` /work/${prevEntry .id } ` }
4654 aria-label = " Previous"
47- class = " py-1 pr-3 pl-1 opacity-60 transition-opacity hover:opacity-100 dark:text-white"
55+ class = " py-1 pr-3 pl-1 opacity-60 transition-opacity hover:opacity-100
56+ dark:text-white"
4857 >
4958 <Icon name = " arrow-left" size = { 20 } />
5059 </a >
@@ -78,7 +87,10 @@ const nextEntry = projects[(currentIndex + 1) % projects.length];
7887 {
7988 tags .map ((tag ) => (
8089 <li class = " leading-none" >
81- <span class = " inline-flex items-center rounded-md px-2 py-1 text-xs font-medium dark:bg-gray-600 dark:text-white" >
90+ <span
91+ class = " inline-flex items-center rounded-md px-2 py-1 text-xs font-medium
92+ dark:bg-gray-600 dark:text-white"
93+ >
8294 { iconMap [tag ] && <Icon name = { iconMap [tag ]} size = { 16 } class = " me-2" />} { tag }
8395 </span >
8496 </li >
0 commit comments