diff --git a/public/covers/dune-placeholder.jpg b/public/covers/dune-placeholder.jpg new file mode 100644 index 0000000..3fd95e9 Binary files /dev/null and b/public/covers/dune-placeholder.jpg differ diff --git a/src/pages/books.astro b/src/pages/books.astro index 7dfb487..3f001c6 100644 --- a/src/pages/books.astro +++ b/src/pages/books.astro @@ -10,7 +10,7 @@ for (const path in bookImports) { const bookModule = await bookImports[path](); allBooksAstro.push({ frontmatter: bookModule.frontmatter, - url: bookModule.url || path.replace('../../content', '').replace('.md', ''), + url: `/books/${path.split('/').pop().replace('.md', '')}`, description: bookModule.frontmatter.description || bookModule.rawContent()?.substring(0, 100) + '...' || 'No description available.', // Ensure all necessary fields for filtering are directly accessible genre: bookModule.frontmatter.genre, diff --git a/src/pages/books/[slug].astro b/src/pages/books/[slug].astro new file mode 100644 index 0000000..aebeadf --- /dev/null +++ b/src/pages/books/[slug].astro @@ -0,0 +1,68 @@ +--- +import { Markdown } from 'astro/components'; + +export async function getStaticPaths() { + console.log('Running getStaticPaths...'); + // Define glob inside the function + const bookImports = import.meta.glob('/content/books/*.md'); + const paths = Object.keys(bookImports); + + console.log('Found file paths:', paths); + + // Process all matched files + const books = await Promise.all( + paths.map(async (path) => { + const mod = await bookImports[path](); + + // Simple slug extraction - just the filename without extension + const filename = path.split('/').pop() || ''; + const slug = filename.replace(/\.md$/, ''); + + console.log(`File: ${filename}, Generated slug: ${slug}`); + console.log(`Debug: Full path=${path}, Normalized URL would be: /books/${slug}`); + + return { + ...mod, + slug, + fullPath: path + }; + }) + ); + + const routes = books.map(book => ({ + params: { slug: book.slug }, + props: { book } + })); + + console.log('Generated routes:', routes.map(r => r.params.slug)); + return routes; +} + +const { book } = Astro.props; +const { frontmatter, compiledContent } = book; +--- + + + + {frontmatter.title || 'Book Details'} + + +
+ ← Back to Books +
+ {frontmatter.title} +

{frontmatter.title}

+

by {frontmatter.author}

+

Genre: {frontmatter.genre}

+

Rating: {frontmatter.rating}/5

+

Year: {frontmatter.year}

+

Status: {frontmatter.status}

+

Pages: {frontmatter.pages}

+

ISBN: {frontmatter.isbn}

+
+ +
+
+
+ +