feat: programmatically generate year book pages

This commit is contained in:
Cory Dransfeldt 2024-07-15 13:52:44 -07:00
parent eed026a6e8
commit b50a4670d2
No known key found for this signature in database
18 changed files with 92 additions and 101 deletions

View file

@ -4,7 +4,7 @@ layout: page
permalink: /about.html
---
{%- assign artist = music.week.artists | first -%}
{%- assign book = books | bookStatus: 'started' | reverse | first -%}
{%- assign book = books.all | bookStatus: 'started' | reverse | first -%}
{%- assign show = tv.recentlyWatched | first -%}
<div class="avatar-wrapper flex-centered">
<div class="interior">

View file

@ -1,7 +1,7 @@
---
layout: default
pagination:
data: books
data: books.all
size: 1
alias: book
permalink: "/books/{{ book.isbn }}/index.html"

View file

@ -6,8 +6,8 @@ permalink: "/books/index.html"
updated: "now"
schema: books
---
{%- assign bookData = books | bookStatus: 'started' | reverse -%}
{%- assign currentBookCount = books | currentBookCount -%}
{%- assign bookData = books.all | bookStatus: 'started' | reverse -%}
{%- assign currentBookCount = books.all | currentBookCount -%}
<h2 class="page-header">Currently reading</h2>
<p>Here's what I'm reading at the moment. I've finished <strong class="highlight-text">{{ currentBookCount }} books</strong> this year.</p>
<p><a href="/books/years/2024">2024</a> / <a href="/books/years/2023">2023</a> / <a href="/books/years/2022">2022</a> / <a href="/books/years/2021">2021</a> / <a href="/books/years/2020">2020</a></p>

View file

@ -0,0 +1,24 @@
---
layout: default
pagination:
data: books.years
size: 1
alias: year
permalink: "/books/years/{{ year.value }}.html"
schema: books-year
---
{%- assign bookData = year.data | bookStatus: 'finished' | bookSortDescending -%}
{%- assign bookDataFavorites = bookData | bookFavorites -%}
{%- capture favoriteBooks -%}{{ bookDataFavorites | shuffleArray | mediaLinks: "book", 5 }}{%- endcapture -%}
{%- capture currentYear -%}{% currentYear %}{%- endcapture -%}
{%- assign yearString = year.value | append: '' -%}
{%- assign currentYearString = currentYear | append: '' -%}
<a class="back-link-header link-icon" href="/books" title="Go back to the books index page">{% tablericon "arrow-left" "Go back to the books index page" %} Back to books</a>
<h2 class="page-header">{{ year.value }} / Books</h2>
{% if yearString == currentYearString %}
<p>I've finished <strong class="highlight-text">{{ bookData.size }} books</strong> this year. Among my favorites are {{ favoriteBooks }}.</p>
{% else %}
<p>I finished <strong class="highlight-text">{{ bookData.size }} books</strong> in <strong class="highlight-text">{{ year.value }}</strong>. Among my favorites were {{ favoriteBooks }}.</p>
{% endif %}
<hr />
{% render "partials/media/grid.liquid", data:bookData, shape: "vertical", count: 200, loading: "eager" %}

View file

@ -1,9 +0,0 @@
---
title: 2020 / Books
description: "This is everything I read in 2020. My favorites were: every book in The Expanse series and I'll Be Gone in the Dark. I finished 34 books in 2020."
year: 2020
layout: partials/media/books/year
permalink: "/books/years/2020.html"
schema: books
---
<p>This is everything I read in 2020. My favorites were: every book in <em>The Expanse</em> series and <em>I'll Be Gone in the Dark</em>.</p>

View file

@ -1,9 +0,0 @@
---
title: 2021 / Books
description: "This is everything I read in 2021. My favorites were: This Is How They Tell Me The World Ends, Sandworm, Empire of Pain, Say Nothing, Sigh, Gone and Leviathan Falls. I finished 53 books in 2021."
year: 2021
layout: partials/media/books/year
permalink: "/books/years/2021.html"
schema: books
---
<p>This is everything I read in 2021. My favorites were: <em>This Is How They Tell Me The World Ends</em>, <em>Sandworm</em>, <em>Empire of Pain</em>, <em>Say Nothing</em>, <em>Sigh, Gone</em> and <em>Leviathan Falls</em>.</p>

View file

@ -1,9 +0,0 @@
---
title: 2022 / Books
description: "This is everything I read in 2022. My favorites were: Sellout, The Sins of Our Fathers, Drive, Adnan's Story and The Lazarus Heist. I finished 67 books in 2022."
year: 2022
layout: partials/media/books/year
permalink: "/books/years/2022.html"
schema: books
---
<p>This is everything I read in 2022. My favorites were: <em>Sellout</em>, <em>The Sins of Our Fathers</em>, <em>Drive</em>, <em>Adnan's Story</em> and <em>The Lazarus Heist</em>.</p>

View file

@ -1,9 +0,0 @@
---
title: 2023 / Books
description: "This is everything I read in 2023. My favorites were: Stay True, Where Are Your Boys Tonight?, Trouble Boys, Tracers in the Dark and Girl in a Band. I finished 69 books in 2023."
year: 2023
layout: partials/media/books/year
permalink: "/books/years/2023.html"
schema: books
---
<p>This is everything I read in 2023. My favorites were: <em>Stay True</em>, <em>Where Are Your Boys Tonight?</em>, <em>Trouble Boys</em>, <em>Tracers in the Dark</em> and <em>Girl in a Band</em>.</p>

View file

@ -1,9 +0,0 @@
---
title: 2024 / Books
description: "Here's what I'm reading at the moment."
year: 2024
layout: partials/media/books/year
permalink: "/books/years/2024.html"
schema: books
---
<p>This is everything I've read in 2024 — continuing my trend of concentrating on science fiction, tech coverage, pop sci, autobiographies and coverage of musicians I appreciate.</p>