diff --git a/src/db/index.ts b/src/db/index.ts index 5ebbdd2..a24d21e 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,5 +1,6 @@ import { Database } from 'bun:sqlite'; import path from 'path'; +import { calculateReadTime } from '../frontend/utils'; /** * Singleton database connection class for managing blog posts and tags @@ -101,7 +102,7 @@ class DatabaseConnection { filePath ? String(filePath) : null, title ? String(title) : null, date ? (date instanceof Date ? date.toISOString().split('T')[0] : String(date)) : null, - readingTime ? String(readingTime) : null, + readingTime ? String(readingTime) : calculateReadTime(content), excerpt ? String(excerpt) : null, content ? String(content) : null ]; @@ -269,15 +270,7 @@ class DatabaseConnection { // Add tags to each post and clean up paths return posts.map(post => { - const basePost = post satisfies { - id: number, - path: string, - title: string, - date: string, - readingTime: string, - summary: string, - content: string - }; + const basePost = { ...post, readingTime: post.reading_time} return { ...basePost, diff --git a/src/frontend/pages/home.tsx b/src/frontend/pages/home.tsx index 3dce94c..68fb0b0 100644 --- a/src/frontend/pages/home.tsx +++ b/src/frontend/pages/home.tsx @@ -57,7 +57,7 @@ function PostCard({ post }: { post: Post }) {