@@ -4,9 +4,9 @@ import { Icon } from "astro-icon/components";
44import { url } from " ../../utils/url-utils" ;
55
66interface Props {
7- page: Page ;
8- class? : string ;
9- style? : string ;
7+ page: Page ;
8+ class? : string ;
9+ style? : string ;
1010}
1111
1212const { page, style } = Astro .props ;
@@ -23,17 +23,17 @@ let count = 1;
2323let l = page .currentPage ;
2424let r = page .currentPage ;
2525while (0 < l - 1 && r + 1 <= page .lastPage && count + 2 <= VISIBLE ) {
26- count += 2 ;
27- l -- ;
28- r ++ ;
26+ count += 2 ;
27+ l -- ;
28+ r ++ ;
2929}
3030while (0 < l - 1 && count < VISIBLE ) {
31- count ++ ;
32- l -- ;
31+ count ++ ;
32+ l -- ;
3333}
3434while (r + 1 <= page .lastPage && count < VISIBLE ) {
35- count ++ ;
36- r ++ ;
35+ count ++ ;
36+ r ++ ;
3737}
3838
3939let pages: number [] = [];
@@ -46,39 +46,69 @@ if (r === page.lastPage - 2) pages.push(page.lastPage - 1);
4646if (r < page .lastPage ) pages .push (page .lastPage );
4747
4848const getPageUrl = (p : number ) => {
49- if (p === 1 ) return " /" ;
50- return ` /${p }/ ` ;
49+ if (p === 1 ) return " /writeups /" ;
50+ return ` /writeups /${p }/` ;
5151};
5252---
5353
54- <div class:list ={ [className , " flex flex-row gap-3 justify-center" ]} style ={ style } >
55- <a href ={ page .url .prev || " " } aria-label ={ page .url .prev ? " Previous Page" : null }
56- class:list ={ [" btn-card overflow-hidden rounded-lg text-[var(--primary)] w-11 h-11" ,
57- {" disabled" : page .url .prev == undefined }
58- ]}
54+ <div
55+ class:list ={ [className , " flex flex-row gap-3 justify-center" ]}
56+ style ={ style }
57+ >
58+ <a
59+ href ={ page .url .prev || " " }
60+ aria-label ={ page .url .prev ? " Previous Page" : null }
61+ class:list ={ [
62+ " btn-card overflow-hidden rounded-lg text-[var(--primary)] w-11 h-11" ,
63+ { disabled: page .url .prev == undefined },
64+ ]}
5965 >
60- <Icon name =" material-symbols:chevron-left-rounded" class =" text-[1.75rem]" ></Icon >
66+ <Icon
67+ name =" material-symbols:chevron-left-rounded"
68+ class =" text-[1.75rem]"
69+ />
6170 </a >
62- <div class =" bg-[var(--card-bg)] flex flex-row rounded-lg items-center text-neutral-700 dark:text-neutral-300 font-bold" >
63- { pages .map ((p ) => {
64- if (p == HIDDEN )
65- return <Icon name = " material-symbols:more-horiz" class = " mx-1" />;
66- if (p == page .currentPage )
67- return <div class = " h-11 w-11 rounded-lg bg-[var(--primary)] flex items-center justify-center
71+ <div
72+ class =" bg-[var(--card-bg)] flex flex-row rounded-lg items-center text-neutral-700 dark:text-neutral-300 font-bold"
73+ >
74+ {
75+ pages .map ((p ) => {
76+ if (p == HIDDEN )
77+ return (
78+ <Icon name = " material-symbols:more-horiz" class = " mx-1" />
79+ );
80+ if (p == page .currentPage )
81+ return (
82+ <div
83+ class = " h-11 w-11 rounded-lg bg-[var(--primary)] flex items-center justify-center
6884 font-bold text-white dark:text-black/70"
69- >
70- { p }
71- </div >
72- return <a href = { url (getPageUrl (p ))} aria-label = { ` Page ${p } ` }
73- class = " btn-card w-11 h-11 rounded-lg overflow-hidden active:scale-[0.85]"
74- >{ p } </a >
75- })}
85+ >
86+ { p }
87+ </div >
88+ );
89+ return (
90+ <a
91+ href = { url (getPageUrl (p ))}
92+ aria-label = { ` Page ${p } ` }
93+ class = " btn-card w-11 h-11 rounded-lg overflow-hidden active:scale-[0.85]"
94+ >
95+ { p }
96+ </a >
97+ );
98+ })
99+ }
76100 </div >
77- <a href ={ page .url .next || " " } aria-label ={ page .url .next ? " Next Page" : null }
78- class:list ={ [" btn-card overflow-hidden rounded-lg text-[var(--primary)] w-11 h-11" ,
79- {" disabled" : page .url .next == undefined }
80- ]}
101+ <a
102+ href ={ page .url .next || " " }
103+ aria-label ={ page .url .next ? " Next Page" : null }
104+ class:list ={ [
105+ " btn-card overflow-hidden rounded-lg text-[var(--primary)] w-11 h-11" ,
106+ { disabled: page .url .next == undefined },
107+ ]}
81108 >
82- <Icon name =" material-symbols:chevron-right-rounded" class =" text-[1.75rem]" ></Icon >
109+ <Icon
110+ name =" material-symbols:chevron-right-rounded"
111+ class =" text-[1.75rem]"
112+ />
83113 </a >
84- </div >
114+ </div >
0 commit comments