www.git

www

~ Personal site — projects, posts, about. Built with sqzass.
git clone https://github.com/debuman/www.git

templates/partials/ledger.html (2023B)

      1 {#- 원장. 왼쪽 고정폭 거터에 날짜, 오른쪽에 제목과 한 줄 설명. 행 사이에 선은
      2     없다 — 간격과 빛이 나눈다.
      3 
      4     날짜는 "JUN 30" 꼴이다. sqzass 에 서식 필터가 없어서 월 이름을 여기서
      5     만드는데, 그게 오히려 맞다 — 서식 미니 언어를 하나 더 배우는 것보다
      6     배열 한 줄이 읽기 쉽다. 한국어에서는 숫자가 낫다: 영어 약어를 한글 사이에
      7     섞으면 그 줄만 다른 언어가 된다.
      8 
      9     `limit` 0 이면 전부, `skip` 은 앞에서 건너뛸 개수. 홈에서 맨 위 글을 크게
     10     따로 내고 나머지를 이어 붙일 때 쓴다. #}
     11 {%- set MON = ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"] %}
     12 
     13 {#- 언어는 인자로 받는다. 목록 항목(PageRefCtx)에는 title·description·url·
     14     weight·date 만 있고 language 는 없다 — 부르는 쪽이 page.language 를 안다. #}
     15 {% macro ledger(children, limit, show_year, skip, lang) %}
     16 <ol class="ledger">
     17   {%- for c in children %}
     18   {%- if loop.index > skip and (limit == 0 or loop.index <= skip + limit) %}
     19   {%- if show_year and c.date and loop.changed(c.date.year) %}
     20   <li class="ledger-year"><span aria-hidden="true">{{ c.date.year }}</span></li>
     21   {%- endif %}
     22   <li>
     23     <a class="ledger-link" href="{{ c.url }}">
     24       {%- if c.date %}
     25       <time class="ledger-date" datetime="{{ c.date.date }}">
     26         {%- if lang == "ko" %}{{ c.date.month }}월 {{ c.date.day }}일
     27         {%- else %}{{ MON[c.date.month - 1] }} {% if c.date.day < 10 %}0{% endif %}{{ c.date.day }}
     28         {%- endif %}
     29       </time>
     30       {%- else %}
     31       <span class="ledger-date" aria-hidden="true">—</span>
     32       {%- endif %}
     33       <span class="ledger-body">
     34         <span class="ledger-title">{{ c.title }}</span>
     35         {%- if c.description %}
     36         <span class="ledger-desc">{{ c.description }}</span>
     37         {%- endif %}
     38       </span>
     39     </a>
     40   </li>
     41   {%- endif %}
     42   {%- endfor %}
     43 </ol>
     44 {% endmacro %}