Add basic tag support for showing and filtering tagged posts
This commit is contained in:
@@ -3,12 +3,16 @@ import { getRecentPosts, formatDate, calculateReadTime, getNumOfPosts } from '..
|
||||
import { parseTags } from '../../db/tags';
|
||||
import { type BlogPost } from '../../db/queries';
|
||||
|
||||
export function Home({ searchParams }: { searchParams: Record<string, string> }) {
|
||||
const currentPage = parseInt(searchParams.page || "1", 10);
|
||||
export function Home({ searchParams }: { searchParams: URLSearchParams }) {
|
||||
const postsPerPage = 10;
|
||||
const totalPages = Math.ceil(getNumOfPosts() / postsPerPage);
|
||||
const tags = searchParams.getAll('tag');
|
||||
|
||||
const currentPage = parseInt(searchParams.get('page') || "1", 10);
|
||||
const totalPages = Math.ceil(getNumOfPosts(tags) / postsPerPage);
|
||||
const offset = (currentPage - 1) * postsPerPage;
|
||||
const posts = getRecentPosts(postsPerPage, offset); // Get posts for the current page
|
||||
|
||||
|
||||
const posts = getRecentPosts(postsPerPage, offset, tags); // Get posts for the current page
|
||||
|
||||
return (
|
||||
<main>
|
||||
|
||||
Reference in New Issue
Block a user