Skip to content

Commit 0f35c72

Browse files
fix(pagination): 페이지 변경 시 동일 목록 표시되는 버그 수정
paginator.page 기반 offset으로 한국어 포스트 페이지별 분리, paginate 값 30으로 조정 (7페이지), 페이지네이션 UI 추가
1 parent dee22b6 commit 0f35c72

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ plugins:
4444
- jekyll-paginate
4545

4646
# Pagination
47-
paginate: 10
47+
paginate: 30
4848
paginate_path: "/page:num/"
4949

5050
# Include in processing

assets/css/main.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,42 @@ a:hover {
646646
text-decoration: underline;
647647
}
648648

649+
/* Pagination */
650+
.pagination {
651+
display: flex;
652+
justify-content: center;
653+
align-items: center;
654+
gap: var(--spacing-lg);
655+
padding: var(--spacing-xl) 0;
656+
margin-top: var(--spacing-lg);
657+
border-top: 1px solid var(--border);
658+
}
659+
660+
.pagination-btn {
661+
padding: var(--spacing-sm) var(--spacing-lg);
662+
border-radius: var(--radius-md);
663+
font-size: var(--font-size-sm);
664+
font-weight: 500;
665+
color: var(--text-primary);
666+
text-decoration: none;
667+
transition: background-color 0.2s, color 0.2s;
668+
}
669+
670+
.pagination-btn:hover {
671+
background-color: var(--bg-secondary);
672+
}
673+
674+
.pagination-btn.disabled {
675+
color: var(--text-tertiary);
676+
pointer-events: none;
677+
}
678+
679+
.pagination-info {
680+
font-size: var(--font-size-sm);
681+
color: var(--text-secondary);
682+
font-weight: 500;
683+
}
684+
649685
/* ===========================
650686
10. POST & PAGE LAYOUT
651687
=========================== */

index.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ <h2>{{ lang_data.posts.recent }}</h2>
2727

2828
<div class="posts-list">
2929
{% assign korean_posts = site.posts | where: "lang", "ko" %}
30-
{% for post in korean_posts limit:20 %}
30+
{% assign posts_per_page = 10 %}
31+
{% assign current_page = paginator.page | default: 1 %}
32+
{% assign offset_val = current_page | minus: 1 | times: posts_per_page %}
33+
{% for post in korean_posts limit: posts_per_page offset: offset_val %}
3134
<article class="post-item">
3235
<h3 class="post-title">
3336
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
@@ -48,6 +51,35 @@ <h3 class="post-title">
4851
</article>
4952
{% endfor %}
5053
</div>
54+
55+
{% assign total_korean = korean_posts | size %}
56+
{% assign total_pages = total_korean | divided_by: posts_per_page %}
57+
{% assign remainder = total_korean | modulo: posts_per_page %}
58+
{% if remainder > 0 %}
59+
{% assign total_pages = total_pages | plus: 1 %}
60+
{% endif %}
61+
62+
{% if total_pages > 1 %}
63+
<nav class="pagination" aria-label="페이지 네비게이션">
64+
{% if current_page > 1 %}
65+
{% if current_page == 2 %}
66+
<a href="/" class="pagination-btn pagination-prev">← {{ lang_data.posts.prev_page | default: "이전" }}</a>
67+
{% else %}
68+
<a href="/page{{ current_page | minus: 1 }}/" class="pagination-btn pagination-prev">← {{ lang_data.posts.prev_page | default: "이전" }}</a>
69+
{% endif %}
70+
{% else %}
71+
<span class="pagination-btn pagination-prev disabled">← {{ lang_data.posts.prev_page | default: "이전" }}</span>
72+
{% endif %}
73+
74+
<span class="pagination-info">{{ current_page }} / {{ total_pages }}</span>
75+
76+
{% if current_page < total_pages %}
77+
<a href="/page{{ current_page | plus: 1 }}/" class="pagination-btn pagination-next">{{ lang_data.posts.next_page | default: "다음" }} →</a>
78+
{% else %}
79+
<span class="pagination-btn pagination-next disabled">{{ lang_data.posts.next_page | default: "다음" }} →</span>
80+
{% endif %}
81+
</nav>
82+
{% endif %}
5183
</section>
5284
</div>
5385
</div>

0 commit comments

Comments
 (0)