-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
286 additions
and
53 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
import { | ||
Pagination as PaginationShadcn, | ||
PaginationContent, | ||
PaginationItem, | ||
PaginationLink, | ||
PaginationNext, | ||
PaginationPrevious, | ||
} from "./ui/pagination"; | ||
interface Props { | ||
currentPage?: number | undefined; | ||
basePath: string; | ||
pageCount: number; | ||
} | ||
const { basePath, currentPage, pageCount } = Astro.props; | ||
--- | ||
|
||
<PaginationShadcn> | ||
<PaginationContent> | ||
{ | ||
currentPage && currentPage > 1 && ( | ||
<PaginationItem> | ||
<PaginationPrevious href={`${basePath}${currentPage - 1}`} /> | ||
</PaginationItem> | ||
) | ||
} | ||
{ | ||
Array.from({ length: pageCount }).map((_, index) => { | ||
const page = index + 1; | ||
return ( | ||
<PaginationItem> | ||
<PaginationLink href={`${basePath}${page}`} isActive={currentPage === page}>{page}</PaginationLink> | ||
</PaginationItem> | ||
); | ||
}) | ||
} | ||
{ | ||
currentPage && currentPage < pageCount && ( | ||
<PaginationItem> | ||
<PaginationNext href={`${basePath}${currentPage + 1}`} /> | ||
</PaginationItem> | ||
) | ||
} | ||
</PaginationContent> | ||
</PaginationShadcn> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
import { getPageCount } from "@/scripts/content_utils"; | ||
import Pagination from "./Pagination.astro"; | ||
import PostsList from "./PostsList.astro"; | ||
import { getPostsFromPage } from "@/scripts/content_fetcher"; | ||
interface Props { | ||
currentPage: number; | ||
} | ||
const { currentPage } = Astro.props; | ||
const basePath = "/posts/"; | ||
const pageCount = await getPageCount(); | ||
const pagePosts = await getPostsFromPage(currentPage); | ||
--- | ||
|
||
<div class="flex flex-col justify-center gap-5"> | ||
<PostsList posts={pagePosts} /> | ||
{ | ||
pageCount !== 1 && ( | ||
<Pagination | ||
pageCount={pageCount} | ||
currentPage={currentPage} | ||
basePath={basePath} | ||
/> | ||
) | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: "dummy1" | ||
title: "Draft Test 1" | ||
author: rog | ||
date: 2024-04-13 | ||
draft: false | ||
tags: | ||
- "dumy" | ||
postType: "Dumy" | ||
description: "1 - This is a dummy post, is just to fill content in the blog 😜." | ||
image: { | ||
"src": "/images/posts/dummy.jpg", | ||
"alt": "Hello World", | ||
"href": "https://www.pexels.com/pt-br/foto/papel-de-parede-digital-de-luz-roxa-e-azul-3780104/" | ||
} | ||
--- | ||
|
||
# Dumy 1 | ||
|
||
This is a dummy post, is just to fill content in the blog 😜. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: "dummy2" | ||
title: "Draft Test 2" | ||
author: rog | ||
date: 2024-04-13 | ||
draft: false | ||
tags: | ||
- "dumy" | ||
postType: "Dumy" | ||
description: "2 - This is a dummy post, is just to fill content in the blog 😜." | ||
image: { | ||
"src": "/images/posts/dummy.jpg", | ||
"alt": "Hello World", | ||
"href": "https://www.pexels.com/pt-br/foto/papel-de-parede-digital-de-luz-roxa-e-azul-3780104/" | ||
} | ||
--- | ||
|
||
# Dumy 2 | ||
|
||
This is a dummy post, is just to fill content in the blog 😜. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: "dummy3" | ||
title: "Draft Test 3" | ||
author: rog | ||
date: 2024-04-13 | ||
draft: false | ||
tags: | ||
- "dumy" | ||
postType: "Dumy" | ||
description: "3 - This is a dummy post, is just to fill content in the blog 😜." | ||
image: { | ||
"src": "/images/posts/dummy.jpg", | ||
"alt": "Hello World", | ||
"href": "https://www.pexels.com/pt-br/foto/papel-de-parede-digital-de-luz-roxa-e-azul-3780104/" | ||
} | ||
--- | ||
|
||
# Dumy 3 | ||
|
||
This is a dummy post, is just to fill content in the blog 😜. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: "dummy4" | ||
title: "Draft Test 4" | ||
author: rog | ||
date: 2024-04-13 | ||
draft: false | ||
tags: | ||
- "dumy" | ||
postType: "Dumy" | ||
description: "4 - This is a dummy post, is just to fill content in the blog 😜." | ||
image: { | ||
"src": "/images/posts/dummy.jpg", | ||
"alt": "Hello World", | ||
"href": "https://www.pexels.com/pt-br/foto/papel-de-parede-digital-de-luz-roxa-e-azul-3780104/" | ||
} | ||
--- | ||
|
||
# Dumy 4 | ||
|
||
This is a dummy post, is just to fill content in the blog 😜. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: "dummy5" | ||
title: "Draft Test 5" | ||
author: rog | ||
date: 2024-04-13 | ||
draft: false | ||
tags: | ||
- "dumy" | ||
postType: "Dumy" | ||
description: "5 - This is a dummy post, is just to fill content in the blog 😜." | ||
image: { | ||
"src": "/images/posts/dummy.jpg", | ||
"alt": "Hello World", | ||
"href": "https://www.pexels.com/pt-br/foto/papel-de-parede-digital-de-luz-roxa-e-azul-3780104/" | ||
} | ||
--- | ||
|
||
# Dumy 4 | ||
|
||
This is a dummy post, is just to fill content in the blog 😜. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
--- | ||
import PostsList from "../components/PostsList.astro"; | ||
import LayoutPage from "../layouts/LayoutPage.astro"; | ||
import { getPosts } from "../scripts/content_fetcher" | ||
const posts = await getPosts() | ||
import LayoutPage from "@/layouts/LayoutPage.astro"; | ||
import PostsListsPaginated from "@/components/PostsListsPaginated.astro"; | ||
--- | ||
|
||
<LayoutPage> | ||
<PostsList posts={posts} /> | ||
</LayoutPage> | ||
<PostsListsPaginated currentPage={1} /> | ||
</LayoutPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
import type { GetStaticPaths } from "astro"; | ||
import LayoutPage from "@/layouts/LayoutPage.astro"; | ||
import { getPageCount } from "@/scripts/content_utils"; | ||
import PostsList from "@/components/PostsList.astro"; | ||
import { getPostsFromPage } from "@/scripts/content_fetcher"; | ||
import PostsListsPaginated from "@/components/PostsListsPaginated.astro"; | ||
export const getStaticPaths = (async () => { | ||
const availablePages = await getPageCount() | ||
const paths = Array.from<GetStaticPaths>({ length: availablePages }).map((_, index) => { | ||
const page = index + 1 | ||
return { | ||
params: { | ||
page: page.toString() | ||
}, | ||
} | ||
}) | ||
return paths | ||
}) satisfies GetStaticPaths; | ||
const { page } = Astro.params | ||
const intPage = parseInt(page) | ||
--- | ||
|
||
<LayoutPage> | ||
<PostsListsPaginated currentPage={intPage} /> | ||
</LayoutPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const POSTS_PER_PAGE = 5; |
Oops, something went wrong.