chore(reading/index.php.liquid): hide books that are no longer started

This commit is contained in:
Cory Dransfeldt 2025-06-15 15:38:44 -07:00
parent 3f685720ce
commit 9e181363dd
No known key found for this signature in database
5 changed files with 47 additions and 42 deletions

View file

@ -18,12 +18,15 @@ class BookProgressHandler extends BaseHandler
} }
} }
$response = $this->makeRequest('GET', 'optimized_books_progress?select=isbn,progress'); $response = $this->makeRequest('GET', 'optimized_books_progress?select=isbn,progress,status');
$result = []; $result = [];
foreach ($response as $row) { foreach ($response as $row) {
if (!empty($row['isbn'])) { if (!empty($row['isbn'])) {
$result[$row['isbn']] = (int) $row['progress']; $result[$row['isbn']] = [
'progress' => (int) $row['progress'],
'status' => $row['status'] ?? null,
];
} }
} }

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "10.6.1", "version": "10.6.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "10.6.1", "version": "10.6.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"minisearch": "^7.1.2", "minisearch": "^7.1.2",

View file

@ -1,6 +1,6 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "10.6.1", "version": "10.6.2",
"description": "The source for my personal site. Built using 11ty (and other tools).", "description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module", "type": "module",
"engines": { "engines": {

View file

@ -1,7 +1,8 @@
CREATE OR REPLACE VIEW optimized_books_progress AS CREATE OR REPLACE VIEW optimized_books_progress AS
SELECT SELECT
isbn, isbn,
progress progress,
status
FROM FROM
optimized_books optimized_books
WHERE WHERE

View file

@ -33,42 +33,43 @@ eleventyComputed:
%} %}
<hr /> <hr />
{% for book in bookData %} {% for book in bookData %}
{% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %} <?php
<article class="book-entry"> $isbn = '{{ book.isbn | escape }}';
<a href="{{ book.url }}"> $entry = $progressData[$isbn] ?? null;
<img if ($entry && ($entry['status'] ?? '') === 'started'):
srcset=" ?>
{{ book.image }}?class=verticalsm&type=webp 200w, {% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %}
{{ book.image }}?class=verticalmd&type=webp 400w <article class="book-entry">
"
sizes="(max-width: 450px) 200px,
400px"
src="{{ book.image }}?class=verticalsm&type=webp"
alt="{{ alt | replaceQuotes }}"
loading="lazy"
decoding="async"
width="200"
height="307"
>
</a>
<div class="media-meta">
<a href="{{ book.url }}"> <a href="{{ book.url }}">
<h2>{{ book.title }}</h2> <img
srcset="
{{ book.image }}?class=verticalsm&type=webp 200w,
{{ book.image }}?class=verticalmd&type=webp 400w
"
sizes="(max-width: 450px) 200px,
400px"
src="{{ book.image }}?class=verticalsm&type=webp"
alt="{{ alt | replaceQuotes }}"
loading="lazy"
decoding="async"
width="200"
height="307"
>
</a> </a>
{% if book.author %} <div class="media-meta">
<span class="sub-meta">By {{ book.author }}</span> <a href="{{ book.url }}">
{% endif %} <h2>{{ book.title }}</h2>
<?php </a>
$isbn = '{{ book.isbn | escape }}'; {% if book.author %}
$progress = $progressData[$isbn] ?? null; <span class="sub-meta">By {{ book.author }}</span>
if (isset($progress)): {% endif %}
?> <progress value="<?= htmlspecialchars($entry['progress']) ?>" max="100">
<progress value="<?= htmlspecialchars($progress) ?>" max="100"><?= htmlspecialchars($progress) ?>%</progress> <?= htmlspecialchars($entry['progress']) ?>%
<?php endif; ?> </progress>
{% if book.description %} {% if book.description %}
<div class="description">{{ book.description | normalize_whitespace | markdown | htmlTruncate }}</div> <div class="description">{{ book.description | normalize_whitespace | markdown | htmlTruncate }}</div>
{% endif %} {% endif %}
</div> </div>
</article> </article>
<?php endif; ?>
{% endfor %} {% endfor %}