diff options
| author | Matthew Kosarek <matthew@matthewkosarek.xyz> | 2026-08-09 19:32:06 -0400 |
|---|---|---|
| committer | Matthew Kosarek <matthew@matthewkosarek.xyz> | 2026-08-09 19:32:06 -0400 |
| commit | edd3b0972115ebddd068ed226158ace07c706401 (patch) | |
| tree | eca3a2ffc85283a99bbce1e7b0068ff5caa78f58 /src/components | |
| parent | e51d273eff923a2c0c691d6f1d740bde74d05b56 (diff) | |
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/ReadingEntry.astro | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/components/ReadingEntry.astro b/src/components/ReadingEntry.astro new file mode 100644 index 0000000..3fa7860 --- /dev/null +++ b/src/components/ReadingEntry.astro @@ -0,0 +1,62 @@ +--- +import type { CollectionEntry } from "astro:content"; + +type ReadingYear = CollectionEntry<"reading">; +type Entry = ReadingYear["data"]["entries"][number]; + +interface Props { + entry: Entry; +} + +const { entry } = Astro.props; + +const href = + entry.url ?? + (entry.isbn ? `https://openlibrary.org/isbn/${entry.isbn}` : undefined); +const isReading = entry.status === "reading"; +const statusLabel = isReading ? "Currently reading" : "Finished"; +--- + +<li> + <p> + <span + class:list={[ + "reading-status", + isReading ? "reading-status--reading" : "reading-status--done", + ]} + role="img" + aria-label={statusLabel} + title={statusLabel} + > + { + !isReading && ( + <svg viewBox="0 0 16 16" aria-hidden="true"> + <path d="M3.6 8.4 6.4 11.2 12.4 4.8" /> + </svg> + ) + } + </span> + { + href ? ( + <a href={href} target="_blank" rel="noopener noreferrer">{entry.title}</a> + ) : ( + <span class="reading-title">{entry.title}</span> + ) + } + {entry.author && <span class="reading-author">by {entry.author}</span>} + </p> + {entry.note && <div class="reading-note">{entry.note}</div>} + { + entry.isbn && ( + <div class="reading-isbn"> + <a + href={`https://openlibrary.org/isbn/${entry.isbn}`} + target="_blank" + rel="noopener noreferrer" + > + ISBN {entry.isbn} + </a> + </div> + ) + } +</li> |
