diff --git a/content/books/1984.md b/content/books/1984.md new file mode 100644 index 0000000..8483c66 --- /dev/null +++ b/content/books/1984.md @@ -0,0 +1,10 @@ +--- +title: '1984' +author: George Orwell +stars: 3 +readDate: 2023-07-31T23:00:00.000Z +url: 'https://app.thestorygraph.com/books/6ff3f487-8d37-4ac5-8190-6622d6562639' +thumbnailUrl: 'https://cdn.thestorygraph.com/v43bj24inkwioiogb5uz8nqmpnpw' +tags: 'fiction, dystopian, classics' +--- + diff --git a/content/books/A-Monster-Calls.md b/content/books/A-Monster-Calls.md new file mode 100644 index 0000000..96b2b31 --- /dev/null +++ b/content/books/A-Monster-Calls.md @@ -0,0 +1,10 @@ +--- +title: A Monster Calls +author: Patrick Ness +stars: 4 +readDate: 2024-05-31T23:00:00.000Z +url: 'https://app.thestorygraph.com/books/170c1204-1410-4246-babb-c80e31aebea9' +thumbnailUrl: 'https://cdn.thestorygraph.com/50qkuazqx2lidfd0hk74ltifz9nf' +tags: 'fiction, young adult' +--- + diff --git a/content/books/Diary-of-An-Oxygen-Thief.md b/content/books/Diary-of-An-Oxygen-Thief.md new file mode 100644 index 0000000..30cc03e --- /dev/null +++ b/content/books/Diary-of-An-Oxygen-Thief.md @@ -0,0 +1,10 @@ +--- +title: Diary of An Oxygen Thief +author: Anonymous +stars: 4 +readDate: 2024-03-01T00:00:00.000Z +url: 'https://app.thestorygraph.com/books/9ce581f2-d9ac-4be1-abf7-4597684bab7f' +thumbnailUrl: 'https://cdn.thestorygraph.com/l5zkpt8v2wj76ri6nkq7ismqsskl' +tags: 'romance, fiction' +--- + diff --git a/content/books/No-God-But-God.md b/content/books/No-God-But-God.md new file mode 100644 index 0000000..f42ecc1 --- /dev/null +++ b/content/books/No-God-But-God.md @@ -0,0 +1,10 @@ +--- +title: No God But God +author: Reza Aslan +stars: 4 +readDate: 2023-01-01T00:00:00.000Z +url: 'https://app.thestorygraph.com/books/27cb3f11-77c6-4eca-9344-d64885e6f1c4' +thumbnailUrl: 'https://cdn.thestorygraph.com/gf3c92roqrgdbdsgphns5n111t93' +tags: 'non-fiction, religion, history' +--- + diff --git a/content/books/The-Nature-of-Alexander.md b/content/books/The-Nature-of-Alexander.md new file mode 100644 index 0000000..ce7dc6b --- /dev/null +++ b/content/books/The-Nature-of-Alexander.md @@ -0,0 +1,10 @@ +--- +title: The Nature of Alexander +author: Mary Renault +stars: 4.5 +readDate: 2023-03-31T23:00:00.000Z +url: 'https://app.thestorygraph.com/books/bc111e8b-1b3f-466a-9efd-c3316ae4b533' +thumbnailUrl: 'https://cdn.thestorygraph.com/68zjkhp67u2bi6qh3melbyqaly06' +tags: 'non-fiction, history, biography' +--- + diff --git a/src/components/Book/Book.jsx b/src/components/Book/Book.jsx index 53b6bf0..2b5f6fe 100644 --- a/src/components/Book/Book.jsx +++ b/src/components/Book/Book.jsx @@ -1,12 +1,17 @@ import { formatDate } from '@/lib/helpers' import { NextSeo } from 'next-seo' +import Image from 'next/image' import Link from 'next/link' import React from 'react' +import style from "./Book.module.css"; +import ExternalLink from '../ExternalLink/ExternalLink' -function Book ({ attributes, html }) { +function Book({ attributes, html }) { return ( <>

{attributes.title}
by {attributes.author}

+ Back... +
+
- Back... - {attributes.pubdate &&

{formatDate(attributes.pubdate)}

} -
(no review)

' }} /> +
+ +
+
(no review)

' }} /> +

+ Rating: {attributes.stars}/5
+ Read on: {formatDate(attributes.readDate)} +

+

View on The StoryGraph

+
+
diff --git a/src/components/Book/Book.module.css b/src/components/Book/Book.module.css new file mode 100644 index 0000000..d3629a5 --- /dev/null +++ b/src/components/Book/Book.module.css @@ -0,0 +1,34 @@ + +.layout { + display: flex; + flex-direction: row; + gap: 1.25rem; + margin: 1.25rem 0; +} + +.layout:first-child { + flex-grow: 0; + flex-shrink: 0; +} + +.layout:last-child { + flex-grow: 1; +} + +.layout p:first-child { + margin-top: 0; +} + +.thumbnail { + border-radius: 8px; +} + +@media screen and (max-width: 650px) { + .layout { + flex-direction: column-reverse; + } + + .thumbnail { + width: 100%; + } +} \ No newline at end of file diff --git a/src/components/BookListItem/BookListItem.jsx b/src/components/BookListItem/BookListItem.jsx index 164d11e..cb38036 100644 --- a/src/components/BookListItem/BookListItem.jsx +++ b/src/components/BookListItem/BookListItem.jsx @@ -17,7 +17,7 @@ export default function BookListItem ({ href, title, author, stars, readDate, ur

{author}

{tags}

-

{stars}/5

+ {/*

{stars}/5

*/} ) diff --git a/src/components/BookListItem/BookListItem.module.css b/src/components/BookListItem/BookListItem.module.css index d982dd2..a845fe8 100644 --- a/src/components/BookListItem/BookListItem.module.css +++ b/src/components/BookListItem/BookListItem.module.css @@ -18,7 +18,7 @@ .thumb { width: auto; - height: 200px; + height: 290px; background-position: center; background-repeat: no-repeat; background-size: cover; diff --git a/src/components/Grid/Grid.jsx b/src/components/Grid/Grid.jsx index 8637e5f..dc3142a 100644 --- a/src/components/Grid/Grid.jsx +++ b/src/components/Grid/Grid.jsx @@ -3,9 +3,7 @@ import style from './Grid.module.css' export default function Grid ({ columns, children }) { return (
{children}
diff --git a/src/components/Grid/Grid.module.css b/src/components/Grid/Grid.module.css index ea09cda..0a1ae35 100644 --- a/src/components/Grid/Grid.module.css +++ b/src/components/Grid/Grid.module.css @@ -1,4 +1,5 @@ .grid { display: grid; - gap: 25px; -} \ No newline at end of file + grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); + gap: 1rem; +} diff --git a/src/components/StaticContentList/StaticContentList.jsx b/src/components/StaticContentList/StaticContentList.jsx index 64d7ddd..2cffae9 100644 --- a/src/components/StaticContentList/StaticContentList.jsx +++ b/src/components/StaticContentList/StaticContentList.jsx @@ -1,7 +1,7 @@ import { formatDate } from '@/lib/helpers' import Link from 'next/link' -export default function StaticContentList ({ entries, urlPrefix }) { +export default function StaticContentList ({ entries, urlPrefix, max = 0 }) { return ( @@ -12,7 +12,7 @@ export default function StaticContentList ({ entries, urlPrefix }) { {e.attributes.title} - ))} + )).slice(0, max > 0 ? max : entries.length)}
) diff --git a/src/lib/content.js b/src/lib/content.js index 2be0456..d3b08f9 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -66,8 +66,7 @@ export function getContentTags (contentPath) { for (const entry of entries) { if (!entry.attributes.tags) { continue } - const tags = entry.attributes.tags.split(', ') - + const tags = entry.attributes.tags; for (const tag of tags) { allTags[tag] = !allTags[tag] ? 1 : allTags[tag] + 1 } diff --git a/src/lib/helpers.js b/src/lib/helpers.js index 7b53aa0..e6f1287 100644 --- a/src/lib/helpers.js +++ b/src/lib/helpers.js @@ -7,3 +7,13 @@ export function toSlug (input) { export function formatDate (date) { return dateFns.format(Date.parse(date), 'PPP') } + +/** + * Silliness to make sure dates don't get passed to the + * page function below as [object Object] + * @param {*} obj + * @returns + */ +export function stringifyAndParse(obj) { + return JSON.parse(JSON.stringify(obj)); +} \ No newline at end of file diff --git a/src/pages/index.js b/src/pages/index.js index c128d8b..389fb82 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -33,7 +33,7 @@ export default function Home ({ postEntries }) {

Recent posts

- +
diff --git a/src/pages/library/[slug].js b/src/pages/library/[slug].js index f81a5b4..4631999 100644 --- a/src/pages/library/[slug].js +++ b/src/pages/library/[slug].js @@ -2,9 +2,11 @@ import React from 'react' import DefaultLayout from '@/layouts/DefaultLayout/DefaultLayout' import { getStaticEntryPaths, getStaticEntryProps } from '@/lib/content' import Book from '@/components/Book/Book' +import { stringifyAndParse } from '@/lib/helpers' export const getStaticPaths = () => getStaticEntryPaths('./content/books') -export const getStaticProps = (ctx) => getStaticEntryProps('./content/books', ctx) +export const getStaticProps = (ctx) => + stringifyAndParse(getStaticEntryProps('./content/books', ctx)); export default function LibrarySingle ({ attributes, html }) { return ( diff --git a/src/pages/library/index.js b/src/pages/library/index.js index cffd6b7..840db2f 100644 --- a/src/pages/library/index.js +++ b/src/pages/library/index.js @@ -2,6 +2,7 @@ import BookListItem from '@/components/BookListItem/BookListItem' import Grid from '@/components/Grid/Grid' import DefaultLayout from '@/layouts/DefaultLayout/DefaultLayout' import { getStaticEntries } from '@/lib/content' +import { stringifyAndParse } from '@/lib/helpers' import { NextSeo } from 'next-seo' export const Title = 'Library' @@ -14,11 +15,9 @@ export const getStaticProps = () => { return { props: { - // Silliness to make sure dates don't get passed to the - // page function below as [object Object] - bookEntries: JSON.parse(JSON.stringify(bookEntries)) + bookEntries: stringifyAndParse(bookEntries) } - } + }; } export default function Library ({ bookEntries }) { diff --git a/src/styles/globals.css b/src/styles/globals.css index 9444bd2..89a06ac 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -17,4 +17,8 @@ td:first-child { .form-group { margin: 20px 0; +} + +.bold { + font-weight: 700; } \ No newline at end of file