๐Ÿ“˜ [GithubPages] Jekyll hydejack ๊ฒŒ์‹œ๋ฌผ prev, next ๋ฒ„ํŠผ ์ถ”๊ฐ€ - 5

๐Ÿ“˜ [GithubPages] Jekyll hydejack ๊ฒŒ์‹œ๋ฌผ prev, next ๋ฒ„ํŠผ ์ถ”๊ฐ€ - 5

[GithubPages] Jekyll hydejack ํฌ์ŠคํŒ… prev, next ๋ฒ„ํŠผ ์ถ”๊ฐ€


๊ฒŒ์‹œ๋ฌผ์— prev, next ๋ฒ„ํŠผ์„ ์ถ”๊ฐ€ํ•จ์œผ๋กœ์จ ๊ธ€์„ ์ฝ์€ ํ›„ ๋‹ค์‹œ ๋ฉ”๋‰ด๋กœ ๊ฐ€์ง€ ์•Š๊ณ  ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋‹ค์Œ ์ด์–ด์ง„ ๊ธ€๋กœ ์ด์–ด์งˆ ์ˆ˜ ์žˆ๊ณ  ํŠนํžˆ ๋ชจ๋ฐ”์ผ ํ™˜๊ฒฝ์—์„œ ํŽ˜์ด์ง€ ํƒ์ƒ‰ ๋ฒ„ํŠผ์˜ ์กด์žฌ ์œ ๋ฌด๊ฐ€ ํฐ ์ฐจ์ด๋ฅผ ๋งŒ๋“ ๋‹ค. ์ฆ‰ ์œ ์ €์˜ ํŽธ์˜์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ๋ฒ„ํŠผ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค.

Jekyll hydejack ํ…Œ๋งˆ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ prev, next ๋ฒ„ํŠผ ๊ธฐ๋Šฅ์ด ์ œ๊ณต๋œ๋‹ค. ์›ํ•˜๋Š” ํŽ˜์ด์ง€์— include๋งŒ ํ•ด์ฃผ๋ฉด ํŽธ๋ฆฌํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

โœ… _includes/components/pagination.html


# file: `_includes/components/pagination.html`

<h2 class="sr-only">{{ site.data.strings.pagination | default:"Pagination" }}</h2>
<nav class="pagination heading clearfix" role="navigation">
  <ul>
    <li class="pagination-item older" >
      {% assign next_title = site.data.strings.older | default:"Prev" %}
      {% assign next_href = page.next.url %}
      {% include components/link.html rel="next" title=next_title href=next_href %}
    </li>
    <li class="pagination-item newer" >
      {% assign prev_title = site.data.strings.newer | default:"Next" %}
      {% assign prev_href = page.previous.url %}
      {% include components/link.html rel="prev" title=prev_title href=prev_href %}
    </li>
  </ul>
</nav>


โœ… _includes/components/link.html


# file: `_includes/components/link.html`

{% if include.href.size > 0 %}
  <a
    class="{{ include.class }} {{ include.a_class }}"
    href="{{ include.href }}"
    {% if include.rel %}rel="{{ include.rel }}"{% endif %}
    {% if include.property %}property="{{ include.property }}"{% endif %}
  >
    {{- include.title -}}
  </a>
{% else %}
  <span class="{{ include.class }} {{ include.span_class }}">{{ include.title }}</span>
{% endif %}

๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ํŽ˜์ด์ง€ ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์™€ next.url, prev.url ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฐ ๋ฒ„ํŠผ์— ๋งํฌ๋ฅผ ๊ฑธ์–ด์ฃผ๋Š” ๋ฐฉ์‹์ด๋‹ค.

[!note] ์ด์ œ ์›ํ•˜๋Š” ํŽ˜์ด์ง€์— include๋งŒ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ๋‚˜๋Š” list.html, post.html์— include๋ฅผ ํ•ด์ฃผ์—ˆ๋‹ค. {%include components/pagination.html %}


# file: list.html

{{ content }}

{% assign posts = site.categories[page.slug] | default:site.tags[page.slug] | default:site.posts %}

{% assign date_formats  = site.data.strings.date_formats               %}
{% assign list_group_by = date_formats.list_group_by | default:"%Y"    %}
{% assign list_entry    = date_formats.list_entry    | default:"%d %b" %}
{%include components/pagination.html %}
{% assign prev_date = 0 %}
{% if page.no_groups %}<ul class="related-posts">{% endif %}
{% for post in posts %}
  {% assign current_date = post.date | date:list_group_by %}
  {% unless page.no_groups %}{% if current_date != prev_date %}
    {% unless forloop.first %}</ul>{% endunless %}
    <h2 id="{{ list_group_by | slugify }}-{{ current_date | slugify }}" class="hr-bottom">{{ current_date }}</h2>
    <ul class="related-posts">
    {% assign prev_date = current_date %}
  {% endif %}{% endunless %}
  {% include_cached components/post-list-item.html post=post format=list_entry %}
  {% if forloop.last %}</ul>{% endif %}
{% endfor %}

#file: post.html

{% assign version = jekyll.version | split:'.' %}
{% assign major = version[0] | plus:0 %}
{% assign minor = version[1] | plus:0 %}
{% assign patch = version[2] | plus:0 %}

{% include_cached components/post.html post=page no_link_title=true no_excerpt=true hide_image=page.hide_image hide_description=page.hide_description %}
{%include components/pagination.html %}
<!-- {% include components/dingbat.html %} -->

{% assign addons = page.addons | default:site.hydejack.post_addons %}
{% unless addons %}{% assign addons = "about,newsletter,related,random" | split:"," %}{% endunless %}
{% for addon in addons %}
  {% case addon %}
  {% when 'about' %}
     {% include_cached components/about.html author=page.author %}
  {% when 'related' %}
    {% include if-non-null try="components/related-posts.html" %}
  {% when 'comments' %}
    {% include body/comments.html %}
  {% else %}
  {% endcase %}
{% endfor %}

์นดํ…Œ๊ณ ๋ฆฌ ์ •๋ ฌ ๊ธฐ์ค€์€ ์•ŒํŒŒ๋ฒณ์ˆœ ๊ฒŒ์‹œ๋ฌผ ์ •๋ ฌ ๊ธฐ์ค€์€ ๋‚ ์งœ์ˆœ์œผ๋กœ ์ด์ „๊ธ€, ๋‹ค์Œ๊ธ€ ํŽ˜์ด์ง€๊ฐ€ ์ด๋™๋œ๋‹ค. order์— ์ˆœ๋ฒˆ์„ ์ •ํ•ด์„œ ์ •๋ ฌ์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์ง€๋งŒ ๊ธฐํšŒ๊ฐ€ ๋˜๋ฉด ๋‚˜์ค‘์— ํ•„์š”ํ•˜๋ฉด ๊ตฌํ˜„ ํ•ด๋ณผ ์˜ˆ์ •์ด๋‹ค.


Pagination


ยฉ 2025. All rights reserved.

Powered by Hydejack v9.2.1