import { useData } from 'nextra/data' import { format } from 'date-fns' import { useRouter, useSearchParams } from 'next/navigation' import Link from 'next/link' import { twMerge } from 'tailwind-merge' const Blog = () => { const data = useData() const searchParams = useSearchParams() const search = searchParams?.get('category') const router = useRouter() const staticCategories = [ { name: 'Building Jan', id: 'building-jan', }, { name: 'Research', id: 'research', }, { name: 'Guides', id: 'guides', }, ] return (

Blog

The latest updates from Jan. See  Changelog  for more product updates.

  • { router.push(`blog/`) }} className={twMerge( 'cursor-pointer py-1 px-2 lg:px-3 rounded-full', search === null && 'dark:bg-blue-400 bg-blue-500 font-medium text-white' )} >

    All Categories

  • {staticCategories.map((cat, i) => { return (
  • { router.push(`blog/?category=${cat.id}`) }} className={twMerge( 'cursor-pointer py-1 px-2 lg:px-3 rounded-full', cat.id === search && 'dark:bg-blue-400 bg-blue-500 font-medium text-white' )} >

    {cat.name}

  • ) })}
{data ?.filter((post: any) => { if (search) { return post.categories?.includes(String(search)) } else { return post } }) .map((post: any, i: number) => { return (

{format(post?.date, 'MMMM do, yyyy')}

{post?.title}
{post?.description && (

{post?.description}

)} {post?.categories && (
{post.categories.map( (category: string, idx: number) => ( {category.replaceAll('-', ' ')} ) )}
)} {post?.author && (

By {post?.author}

)}
) })}
) } export default Blog