chore(reading/index.php.liquid): hide books that are no longer started
This commit is contained in:
parent
3f685720ce
commit
9e181363dd
5 changed files with 47 additions and 42 deletions
|
@ -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 = [];
|
||||
|
||||
foreach ($response as $row) {
|
||||
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
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "10.6.1",
|
||||
"version": "10.6.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coryd.dev",
|
||||
"version": "10.6.1",
|
||||
"version": "10.6.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minisearch": "^7.1.2",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "10.6.1",
|
||||
"version": "10.6.2",
|
||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
CREATE OR REPLACE VIEW optimized_books_progress AS
|
||||
SELECT
|
||||
isbn,
|
||||
progress
|
||||
progress,
|
||||
status
|
||||
FROM
|
||||
optimized_books
|
||||
WHERE
|
||||
|
|
|
@ -33,42 +33,43 @@ eleventyComputed:
|
|||
%}
|
||||
<hr />
|
||||
{% for book in bookData %}
|
||||
{% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %}
|
||||
<article class="book-entry">
|
||||
<a href="{{ book.url }}">
|
||||
<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>
|
||||
<div class="media-meta">
|
||||
<?php
|
||||
$isbn = '{{ book.isbn | escape }}';
|
||||
$entry = $progressData[$isbn] ?? null;
|
||||
if ($entry && ($entry['status'] ?? '') === 'started'):
|
||||
?>
|
||||
{% capture alt %}{{ book.title }} by {{ book.authors }}{% endcapture %}
|
||||
<article class="book-entry">
|
||||
<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>
|
||||
{% if book.author %}
|
||||
<span class="sub-meta">By {{ book.author }}</span>
|
||||
{% endif %}
|
||||
<?php
|
||||
$isbn = '{{ book.isbn | escape }}';
|
||||
$progress = $progressData[$isbn] ?? null;
|
||||
if (isset($progress)):
|
||||
?>
|
||||
<progress value="<?= htmlspecialchars($progress) ?>" max="100"><?= htmlspecialchars($progress) ?>%</progress>
|
||||
<?php endif; ?>
|
||||
{% if book.description %}
|
||||
<div class="description">{{ book.description | normalize_whitespace | markdown | htmlTruncate }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
<div class="media-meta">
|
||||
<a href="{{ book.url }}">
|
||||
<h2>{{ book.title }}</h2>
|
||||
</a>
|
||||
{% if book.author %}
|
||||
<span class="sub-meta">By {{ book.author }}</span>
|
||||
{% endif %}
|
||||
<progress value="<?= htmlspecialchars($entry['progress']) ?>" max="100">
|
||||
<?= htmlspecialchars($entry['progress']) ?>%
|
||||
</progress>
|
||||
{% if book.description %}
|
||||
<div class="description">{{ book.description | normalize_whitespace | markdown | htmlTruncate }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
<?php endif; ?>
|
||||
{% endfor %}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue