feat(reading/index.php.liquid): update reading progress on page load
This commit is contained in:
parent
320f5e53db
commit
fc32f457c0
7 changed files with 75 additions and 9 deletions
|
@ -1,9 +1,22 @@
|
|||
---
|
||||
title: Reading
|
||||
description: Here's what I'm reading at the moment.
|
||||
permalink: "/reading/index.html"
|
||||
permalink: "/reading/index.php"
|
||||
schema: books
|
||||
eleventyComputed:
|
||||
page:
|
||||
activeUrl: "/reading"
|
||||
---
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../bootstrap.php';
|
||||
|
||||
use App\Classes\BookProgressHandler;
|
||||
|
||||
$progressHandler = new BookProgressHandler();
|
||||
$progressData = $progressHandler->getAllProgress();
|
||||
|
||||
?>
|
||||
{%- assign currentYear = 'now' | date: "%Y" -%}
|
||||
{%- assign bookData = books.all | filterBooksByStatus: 'started' | reverse -%}
|
||||
{%- assign currentBookCount = books.currentYear | size -%}
|
||||
|
@ -45,14 +58,17 @@ schema: books
|
|||
{% if book.author %}
|
||||
<span class="sub-meta">By {{ book.author }}</span>
|
||||
{% endif %}
|
||||
{% if book.progress %}
|
||||
{% render "static/media/progress-bar.liquid",
|
||||
percentage:book.progress
|
||||
%}
|
||||
{% 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>
|
||||
{% endfor %}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue