Skip to content

Commit db93191

Browse files
authored
Merge branch 'json-schema-org:main' into main
2 parents 8401293 + d94a3bc commit db93191

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

pages/blog/index.page.tsx

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default function StaticMarkdownPage({
102102
.split(',')
103103
.filter(isValidCategory);
104104
setCurrentFilterTags(tags.length ? tags : ['All']);
105+
setCurrentPage(1);
105106
}
106107
}, [router.query]);
107108

@@ -190,6 +191,23 @@ export default function StaticMarkdownPage({
190191
});
191192
const allTags = ['All', ...Array.from(allTagsSet)];
192193

194+
// pagination implement
195+
const POSTS_PER_PAGE = 10;
196+
const [currentPage, setCurrentPage] = useState(1);
197+
198+
const totalPages = Math.ceil(sortedFilteredPosts.length / POSTS_PER_PAGE);
199+
200+
useEffect(() => {
201+
if (currentPage > totalPages) {
202+
setCurrentPage(1);
203+
}
204+
}, [totalPages]);
205+
206+
const currentPagePosts = sortedFilteredPosts.slice(
207+
(currentPage - 1) * POSTS_PER_PAGE,
208+
currentPage * POSTS_PER_PAGE,
209+
);
210+
193211
return (
194212
// @ts-ignore
195213
<SectionContext.Provider value='blog'>
@@ -299,8 +317,8 @@ export default function StaticMarkdownPage({
299317
</div>
300318

301319
{/* Blog Posts Grid */}
302-
<div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6 grid-flow-row mb-20 bg-white dark:bg-slate-800 mx-auto p-4'>
303-
{sortedFilteredPosts.map((blogPost: any, idx: number) => {
320+
<div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6 grid-flow-row mb-16 bg-white dark:bg-slate-800 mx-auto p-4'>
321+
{currentPagePosts.map((blogPost: any, idx: number) => {
304322
const { frontmatter, content } = blogPost;
305323
const date = new Date(frontmatter.date);
306324
const postTimeToRead = Math.ceil(readingTime(content).minutes);
@@ -430,6 +448,34 @@ export default function StaticMarkdownPage({
430448
);
431449
})}
432450
</div>
451+
{/* pagination control */}
452+
<div className='flex justify-center items-center gap-4'>
453+
<button
454+
className={`px-4 py-2 rounded-md font-semibold ${
455+
currentPage === 1
456+
? 'bg-gray-300 dark:bg-slate-600 cursor-not-allowed'
457+
: 'bg-blue-600 text-white hover:bg-blue-700'
458+
}`}
459+
disabled={currentPage === 1}
460+
onClick={() => setCurrentPage((p) => p - 1)}
461+
>
462+
Previous
463+
</button>
464+
<span className='text-lg font-medium dark:text-white'>
465+
Page {currentPage} of {totalPages}
466+
</span>
467+
<button
468+
className={`px-4 py-2 rounded-md font-semibold ${
469+
currentPage === totalPages
470+
? 'bg-gray-300 dark:bg-slate-600 cursor-not-allowed'
471+
: 'bg-blue-600 text-white hover:bg-blue-700'
472+
}`}
473+
disabled={currentPage === totalPages}
474+
onClick={() => setCurrentPage((p) => p + 1)}
475+
>
476+
Next
477+
</button>
478+
</div>
433479
</div>
434480
</SectionContext.Provider>
435481
);

pages/index.page.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const Home = (props: any) => {
123123
supadata: '/img/logos/sponsors/supadata-logo-light.svg',
124124
devevents: '/img/logos/dark-mode/dev_events_logo.png',
125125
nix: '/img/logos/sponsors/n-ix-logo.png',
126+
oracle: '/img/logos/sponsors/Oracle.png',
126127
},
127128
lightLogos: {
128129
asyncapi: '/img/logos/sponsors/asyncapi-logo-dark.svg',
@@ -147,6 +148,7 @@ const Home = (props: any) => {
147148
dottxt: '/img/logos/sponsors/dottxt-logo-dark.svg',
148149
devevents: '/img/logos/dark-mode/dev_events_logo.png',
149150
nix: '/img/logos/sponsors/n-ix-logo.png',
151+
oracle: '/img/logos/sponsors/Oracle.png',
150152
},
151153
};
152154

@@ -910,6 +912,17 @@ const Home = (props: any) => {
910912
alt='n-iX logo'
911913
/>
912914
</a>
915+
<a
916+
href='https://www.oracle.com/'
917+
target='_blank'
918+
rel='noreferrer'
919+
>
920+
<img
921+
src={logos.oracle}
922+
className='w-44 transition-transform duration-300 hover:scale-105'
923+
alt='Oracle logo'
924+
/>
925+
</a>
913926
<a
914927
href='https://opencollective.com/json-schema/contribute/sponsor-10816/checkout?interval=month&amount=100&name=&legalName=&email='
915928
target='_blank'

public/_redirects

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
/latest/release-notes /draft/2020-12/release-notes
2222
/implementations /tools 301
2323
/obsolete-implementations /tools?showObsolete=true 301
24-
/slack https://join.slack.com/t/json-schema/shared_invite/zt-2ued3v79g-Tk_aI32ZdW~ST0EWpGBwNQ 301
25-
/slack-redirect https://join.slack.com/t/json-schema/shared_invite/zt-2ued3v79g-Tk_aI32ZdW~ST0EWpGBwNQ 301
24+
# Slack redirect to invite URL is handled by Cloudflare via UI. Not sure why. Maybe to avoid having to wait for a build and deploy.
25+
# /slack https://join.slack.com/t/json-schema/shared_invite/zt-3ktcs18gk-ElYFaGDSOv68OJMf3H4vXg 301
26+
/slack-redirect /slack 301
2627
/understanding-json-schema /understanding-json-schema/reference 301
2728
/understanding-json-schema/conventions /understanding-json-schema/reference 301
28-
/understanding-json-schema/reference/_index.md /understanding-json-schema/reference 301
29+
/understanding-json-schema/reference/_index.md /understanding-json-schema/reference 301
19.8 KB
Loading

0 commit comments

Comments
 (0)