Skip to content

Commit

Permalink
First version of bookshelf page
Browse files Browse the repository at this point in the history
  • Loading branch information
Declan Chidlow committed Dec 10, 2024
1 parent e454074 commit dee9a0c
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/assets/styles/pages/bookshelf.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#books {
display: grid;
grid-template-columns: repeat(1, 1fr);
gap: 0.5rem;
max-width: 90rem;
margin-left: 0;

@media (min-width: 30rem) {
grid-template-columns: repeat(2, 1fr);
gap: 2rem;
}

@media (min-width: 60rem) {
grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 90rem) {
grid-template-columns: repeat(4, 1fr);
}

.book {
display: flex;
flex-direction: column;
gap: 0.25rem;
padding: 0.5rem;
background: var(--grey);
margin-left: 0;

h2 {
font-size: 1.2rem;
line-height: 1.2rem;
text-wrap: initial;
}
}
}
184 changes: 184 additions & 0 deletions src/bookshelf/books.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
- title: Harry Potter and the Methods of Rationality
authors: Eliezer Yudkowsky
read_status: In Progress
- title: Fear and Loathing in Las Vegas
authors: Hunter S. Thompson
read_status: In Progress
- title: Harry Potter and the Deathly Hallows
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Sorcerer's Stone
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Half-Blood Prince
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Chamber of Secrets
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Order of the Phoenix
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Prisoner of Azkaban
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: Harry Potter and the Goblet of Fire
authors: JK Rowling
last_date_read: 2023/12/26
read_status: Read
star_rating: "4.0"
- title: If Only They Could Talk
authors: James Herriot
last_date_read: 2023/04/12
read_status: Read
- title: Spurious Correlations
authors: Tyler Vigen
last_date_read: 2022/12/24
read_status: Read
- title: Of Mice and Men
authors: John Steinbeck
last_date_read: 2022/12/20
read_status: Read
- title: The Restaurant At the End of the Universe
authors: Douglas Adams
last_date_read: 2022/06/05
read_status: Read
star_rating: "4.5"
- title: Varg in Love
authors: Alexander McCall Smith
last_date_read: 2022/06/05
read_status: Read
star_rating: "3.0"
- title: The Hitchhiker's Guide to the Galaxy
authors: Douglas Adams
last_date_read: 2022/05/17
read_status: Read
star_rating: "4.5"
- title: A Clockwork Orange
authors: Anthony Burgess
last_date_read: 2022/04/21
read_status: Read
star_rating: "5.0"
- title: Lost Perth
authors: Warren Duffy
last_date_read: 2022/04/13
read_status: Read
star_rating: "3.5"
- title: "Kitchen Confidential"
authors: Anthony Bourdain
last_date_read: 2022/03/31
read_status: Read
star_rating: "4.0"
- title: Animal Farm
authors: George Orwell
last_date_read: 2022/03/16
read_status: Read
star_rating: "4.5"
- title: Harry Potter and the Cursed Child
authors: Jack Thorne
last_date_read: 2022/03/12
read_status: Read
star_rating: "3.0"
- title: The Ballad of Songbirds and Snakes
authors: Suzanne Collins
last_date_read: 2022/03/10
read_status: Read
star_rating: "4.0"
- title: Mockingjay
authors: Suzanne Collins
last_date_read: 2022/03/03
read_status: Read
star_rating: "4.0"
- title: Catching Fire
authors: Suzanne Collins
last_date_read: 2022/02/28
read_status: Read
star_rating: "4.5"
- title: The Hunger Games
authors: Suzanne Collins
last_date_read: 2022/02/25
read_status: Read
star_rating: "4.5"
- title: Chitty Chitty Bang Bang
authors: Ian Fleming
last_date_read: 2022/02/21
read_status: Read
star_rating: "3.5"
- title: Wonder
authors: RJ Palacio
last_date_read: 2022/02/16
read_status: Read
star_rating: "3.5"
- title: More Rules for Life
authors: Kitty Flanagan
last_date_read: 2022/01/22
read_status: Read
star_rating: "4.0"
- title: 488 Rules for Life
authors: Kitty Flanagan
last_date_read: 2022/01/21
read_status: Read
star_rating: "4.0"
- title: The Meaning of Liff
authors: Douglas Adams, John Lloyd
last_date_read: 2022/01/10
read_status: Read
star_rating: "4.5"
- title: Flowers for Algernon
authors: Daniel Keyes
last_date_read: 2022/01/03
read_status: Read
star_rating: "5.0"
- title: Johnny Got His Gun
authors: Dalton Trumbo
read_status: Did Not Finish
- title: "Hogwarts: An Incomplete and Unreliable Guide"
authors: JK Rowling
read_status: Read
- title: Harry Potter and the Deathly Hallows
authors: JK Rowling
last_date_read: "2022"
read_status: Read
- title: The Great Gatsby
authors: F Scott Fitzgerald
read_status: Did Not Finish
- title: The Tales of Beedle the Bard
authors: JK Rowling
read_status: Read
- title: Quidditch Through the Ages
authors: JK Rowling
read_status: Read
- title: Atomic Habits
authors: James Clear
read_status: Did Not Finish
- title: The Thief
authors: Fuminori Nakamura
read_status: Did Not Finish
- title: The Gospel of the Flying Spaghetti Monster
authors: Bobby Henderson
read_status: Read
- title: Fantastic Beasts & Where to Find Them
authors: JK Rowling
read_status: Read
- title: Short Stories from Hogwarts of Heroism, Hardship and Dangerous Hobbies
authors: JK Rowling
read_status: Read
- title: How to Talk to Girls At Parties
authors: Neil Gaiman
last_date_read: "2022"
read_status: Read
- title: Short Stories from Hogwarts of Power, Politics and Pesky Poltergeists
authors: JK Rowling
read_status: Read
29 changes: 29 additions & 0 deletions src/bookshelf/bookshelf.ori
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(books) => main_template.ori({
title: "Bookshelf"
description: "An index of many of the books I have read and those which I have given up on. Also links to the locations of my reviews across the web."
og_description: "An index of many of the books I have read and those which I have given up on. Also links to the locations of my reviews across the web."

@text: indent`
<link rel="stylesheet" href="/assets/styles/pages/bookshelf.css">

<h1 id="section">Bookshelf</h1>

<div>
<section>
<h2>Books</h2>
<ol id="books">
${ books
→ =sort(_, (book) => new:Date(books/last_date_read))
→ =map(_, (book) => `
<li class="book">
<h2>${ book/title }</h2>
<p>${ book/authors }</p>
<p>${ book/read_status }</p>
<p class="star-rating" title="Rated ${ book/star_rating } out of 5">${ functions/num-to-stars.js(book/star_rating) }</p>
</li>
`) }
</ol>
</section>
</div>
`
})
8 changes: 8 additions & 0 deletions src/functions/num-to-stars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default (rating) => {
const fullStars = Math.floor(rating);
const hasHalfStar = rating % 1 >= 0.5;
const emptyStars = 5 - fullStars - (hasHalfStar ? 1 : 0);

const stars = "★".repeat(fullStars) + (hasHalfStar ? "⯪" : "") + "☆".repeat(emptyStars);
return stars;
};
2 changes: 2 additions & 0 deletions src/site.ori
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
support.html = main_template.ori(functions/parse-markdown.js(pages/support.md))
404.html = main_template.ori(functions/parse-markdown.js(pages/404.md))

bookshelf.html = bookshelf/bookshelf.ori(bookshelf/books.yaml)

posts.html = post_list.ori(post_data.ori)
posts = {
...map(post_data.ori, post_template.ori)
Expand Down

0 comments on commit dee9a0c

Please sign in to comment.