Skip to content

Commit 38a9858

Browse files
1choooZako990131
andauthored
refactor(portfolio): rename variables for clarity and consistency in Portfolio component (#503) (#508)
Co-authored-by: ZAKO_SILENCE <[email protected]> Co-authored-by: Chun-Ho (Hugo) Lin <[email protected]>
1 parent aeb7fa0 commit 38a9858

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

apps/web/src/app/portfolio/page.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,35 @@ export const metadata = {
2727
export default async function Portfolio({ searchParams }: {
2828
readonly searchParams: { tag?: string; page?: string };
2929
}) {
30-
let allBlogs = await getPortfolioPosts();
30+
let allPortfolioPosts = await getPortfolioPosts();
3131
const blogTags = [
3232
"All",
3333
...Array.from(
34-
new Set(allBlogs.map((post) => post.metadata.category ?? ""))
34+
new Set(allPortfolioPosts.map((post) => post.metadata.category ?? ""))
3535
),
3636
];
3737
const selectedTag = searchParams.tag || "All";
3838
const currentPage = parseInt(searchParams.page || "1", 10);
3939

4040
// Filter blogs based on the selected tag
41-
const filteredBlogs =
41+
const filteredPortfolioPosts =
4242
selectedTag === "All"
43-
? allBlogs
44-
: allBlogs.filter((post) => post.metadata.category === selectedTag);
43+
? allPortfolioPosts
44+
: allPortfolioPosts.filter((post) => post.metadata.category === selectedTag);
4545

4646
// Sort blogs by date
47-
const sortedBlogs = filteredBlogs.sort((a, b) => {
47+
const sortedPortfolioPosts = filteredPortfolioPosts.sort((a, b) => {
4848
if (new Date(a.metadata.publishedAt) > new Date(b.metadata.publishedAt)) {
4949
return -1;
5050
}
5151
return 1;
5252
});
5353

5454
// Calculate total pages
55-
const totalPages = Math.ceil(sortedBlogs.length / POSTS_PER_PAGE);
55+
const totalPages = Math.ceil(sortedPortfolioPosts.length / POSTS_PER_PAGE);
5656

5757
// Get blogs for current page
58-
const paginatedBlogs = sortedBlogs.slice(
58+
const paginatedPortfolioPosts = sortedPortfolioPosts.slice(
5959
(currentPage - 1) * POSTS_PER_PAGE,
6060
currentPage * POSTS_PER_PAGE
6161
);
@@ -67,7 +67,7 @@ export default async function Portfolio({ searchParams }: {
6767
<FilterList selectedTag={selectedTag} blogTags={blogTags} />
6868
<FilterSelectBox selectedTag={selectedTag} blogTags={blogTags} />
6969
<ul className="project-list">
70-
{paginatedBlogs.map((post, index) => (
70+
{paginatedPortfolioPosts.map((post, index) => (
7171
<li
7272
key={index}
7373
className="project-item active"

0 commit comments

Comments
 (0)