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,6 +33,11 @@ eleventyComputed:
%} %}
<hr /> <hr />
{% for book in bookData %} {% for book in bookData %}
<?php
$isbn = '{{ book.isbn | escape }}';
$entry = $progressData[$isbn] ?? null;
if ($entry && ($entry['status'] ?? '') === 'started'):
?>
{% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %} {% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %}
<article class="book-entry"> <article class="book-entry">
<a href="{{ book.url }}"> <a href="{{ book.url }}">
@ -58,17 +63,13 @@ eleventyComputed:
{% if book.author %} {% if book.author %}
<span class="sub-meta">By {{ book.author }}</span> <span class="sub-meta">By {{ book.author }}</span>
{% endif %} {% endif %}
<?php <progress value="<?= htmlspecialchars($entry['progress']) ?>" max="100">
$isbn = '{{ book.isbn | escape }}'; <?= htmlspecialchars($entry['progress']) ?>%
$progress = $progressData[$isbn] ?? null; </progress>
if (isset($progress)):
?>
<progress value="<?= htmlspecialchars($progress) ?>" max="100"><?= htmlspecialchars($progress) ?>%</progress>
<?php endif; ?>
{% 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 %}