From cf5f14e8d9b26503c19a05d2074fbd2765fcb1ad Mon Sep 17 00:00:00 2001 From: Chris Chinchilla Date: Thu, 19 Dec 2024 09:49:35 +0100 Subject: [PATCH] Add new books --- src/components/Book.astro | 9 +++-- src/config.mjs | 33 +++++++++++++++++ ...n-12-coobook.md => ableton-12-cookbook.md} | 0 src/content/books/the-dead-among-us.md | 8 +++++ src/pages/books/[...page].astro | 4 +-- src/pages/books/[...slug].astro | 35 +++++++++++++++++++ 6 files changed, 85 insertions(+), 4 deletions(-) rename src/content/books/{ableton-12-coobook.md => ableton-12-cookbook.md} (100%) create mode 100644 src/pages/books/[...slug].astro diff --git a/src/components/Book.astro b/src/components/Book.astro index 31696d27..cc790c55 100644 --- a/src/components/Book.astro +++ b/src/components/Book.astro @@ -85,8 +85,13 @@ var idOfTitle = slugify(book.data.title);
-

- {book.data.title} +

+ + {book.data.title}

{book.data.publisher}, {formattedDate}, {book.data.role}
diff --git a/src/config.mjs b/src/config.mjs index 2f0bf3be..3500d3d4 100644 --- a/src/config.mjs +++ b/src/config.mjs @@ -60,6 +60,9 @@ const CONFIG = { }, }, + + + game: { disabled: false, postsPerPage: 30, @@ -121,6 +124,35 @@ const CONFIG = { }, }, + book: { + disabled: false, + postsPerPage: 15, + // TODO: Change? + list: { + pathname: 'books', // blog main path, you can change this to "articles" (/articles) + noindex: false, + disabled: false, + }, + + post: { + permalink: '/book/%slug%', + // pathname: '', // empty for /some-post, value for /pathname/some-post + noindex: false, + disabled: false, + }, + + category: { + pathname: 'category', // set empty to change from /category/some-category to /some-category + noindex: true, + disabled: false, + }, + + tag: { + pathname: 'tag', // set empty to change from /tag/some-tag to /some-tag + noindex: true, + disabled: false, + }, + }, event: { @@ -185,6 +217,7 @@ const CONFIG = { export const SITE = { ...CONFIG, blog: undefined, client: undefined }; export const BLOG = CONFIG.blog; +export const BOOK = CONFIG.book; export const CLIENT = CONFIG.client; export const EVENT = CONFIG.event; export const GAME = CONFIG.game; diff --git a/src/content/books/ableton-12-coobook.md b/src/content/books/ableton-12-cookbook.md similarity index 100% rename from src/content/books/ableton-12-coobook.md rename to src/content/books/ableton-12-cookbook.md diff --git a/src/content/books/the-dead-among-us.md b/src/content/books/the-dead-among-us.md index 70d0b190..753ec849 100644 --- a/src/content/books/the-dead-among-us.md +++ b/src/content/books/the-dead-among-us.md @@ -7,8 +7,16 @@ image: ~/assets/images/books/the-dead-among-us.png store_urls: - label: eBook - Direct from me (pay what you feel) url: https://ko-fi.com/s/0a76b75a05 + - label: eBook and other perks via Ko-fi + url: https://ko-fi.com/chrischinchilla/tiers + - label: eBook and other perks via Patreon + url: https://www.patreon.com/c/chrischinchilla - label: eBook - Amazon url: https://www.amazon.com/dp/B0DQGRTT11 + - label: eBook - DriveThruFiction + url: https://www.drivethrufiction.com/product/505735/The-dead-among-us + - label: eBook - All other stores + url: https://books2read.com/u/m09D0W --- **Print coming soon!** diff --git a/src/pages/books/[...page].astro b/src/pages/books/[...page].astro index d63323ad..2364ddac 100644 --- a/src/pages/books/[...page].astro +++ b/src/pages/books/[...page].astro @@ -2,7 +2,7 @@ import Layout from '~/layouts/PageLayoutNoBG.astro'; import { Pagination } from 'accessible-astro-components'; import Headline from '~/components/blog/Headline.astro'; -import { BLOG } from '~/config.mjs'; +import { BOOK } from '~/config.mjs'; import Book from '~/components/Book.astro'; import { getCollection } from 'astro:content'; @@ -11,7 +11,7 @@ export async function getStaticPaths({ paginate }) { allBooks = allBooks.sort((a, b) => new Date(b.data.publish_date).valueOf() - new Date(a.data.publish_date).valueOf()); return paginate(allBooks, { - pageSize: BLOG.postsPerPage, + pageSize: BOOK.postsPerPage, }); } diff --git a/src/pages/books/[...slug].astro b/src/pages/books/[...slug].astro new file mode 100644 index 00000000..fba8091a --- /dev/null +++ b/src/pages/books/[...slug].astro @@ -0,0 +1,35 @@ +--- +import MarkdownPostLayout from '../../layouts/MarkdownLayout.astro'; +import { Image } from 'astro:assets'; +import { getCollection } from 'astro:content'; + +export async function getStaticPaths() { + const bookEntries = await getCollection('books'); + return bookEntries.map((entry) => ({ + params: { slug: entry.slug }, + props: { entry }, + })); +} + +const { entry } = Astro.props; +const { Content } = await entry.render(); +--- + + + {entry.data.title} + { + entry.data.store_urls && ( + + Buy a copy in the following places: + + + ) + } + +