Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: minor blogs design change and mobile floating toc

Arghya Dasadd14d1d641c
diff --git a/apps/www/app/(blog)/blog/[...slug]/page.tsx b/apps/www/app/(blog)/blog/[...slug]/page.tsx
index a019c01e..59dc8946 100644
--- a/apps/www/app/(blog)/blog/[...slug]/page.tsx
+++ b/apps/www/app/(blog)/blog/[...slug]/page.tsx
@@ -1,15 +1,17 @@
+/* eslint-disable @next/next/no-img-element */
import type { Metadata } from "next"
import Link from "next/link"
import { notFound } from "next/navigation"
import { mdxComponents } from "@/mdx-components"
import { ArrowLeftIcon } from "lucide-react"
+import { Badge } from "@/components/ui/badge"
import type { BlogPosting, BreadcrumbList, WithContext } from "schema-dts"
-
import { siteConfig } from "@/config/site"
import { blogSource } from "@/lib/source"
import { absoluteUrl, calculateReadingTime, formatDate } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
import { BlogTableOfContents } from "@/components/blog/table-of-contents"
+import { MobileTOC } from "@/components/blog/mobile-toc"
import { SidebarCTA } from "@/components/sidebar-cta"
export const revalidate = false
@@ -182,29 +184,31 @@ export default async function BlogPage({ params }: PageProps) {
<article className="mx-auto mt-5 max-w-6xl rounded-xl">
{doc && (
<div>
- <div className="relative overflow-hidden rounded-xl p-5 md:p-10">
+ <div className="relative overflow-hidden rounded-xl p-5">
<img
src={doc.image}
alt={doc.title}
- className="border-border size-full rounded-xl border object-cover object-left"
+ className="size-full rounded-xl object-cover object-left border border-border"
/>
</div>
- <div className="border-border mx-auto flex flex-col items-center justify-center gap-y-2 border-y p-5">
- <div className="mx-auto flex max-w-4xl flex-col items-center justify-center gap-y-2">
+ <div className="mx-auto flex flex-col items-center justify-center gap-y-2 p-5">
+ <div className="mx-auto flex max-w-3xl flex-col items-center justify-center gap-y-4">
<h1 className="text-center text-3xl font-semibold tracking-tighter text-balance md:text-5xl">
{doc.title}
</h1>
<p className="text-secondary-foreground text-center text-balance md:text-lg">
{doc.description}
</p>
- {doc.publishedOn && (
- <time className="text-secondary-foreground text-sm">
- {formatDate(doc.publishedOn)}
- </time>
- )}
+ <div className="text-secondary-foreground flex items-center justify-center gap-x-2 text-sm">
+ {doc.publishedOn && (
+ <time>{formatDate(doc.publishedOn)}</time>
+ )}
+ {doc.publishedOn && <span>·</span>}
+ <span>{calculateReadingTime(content)} min read</span>
+ </div>
</div>
</div>
- <div className="border-border text-secondary-foreground flex items-center justify-center gap-x-2 border-b p-3 text-sm">
+ <div className="text-secondary-foreground flex items-center justify-center gap-x-2 p-3 text-sm">
{(() => {
const docTag = doc.tags
const tags = docTag
@@ -215,21 +219,19 @@ export default async function BlogPage({ params }: PageProps) {
return (
tags.length > 0 && (
- <>
- <span>{calculateReadingTime(content)} min read</span>
- <span>·</span>
- <div className="flex flex-wrap gap-1">
- {tags.map((tag) => (
- <Link
- key={tag}
- href={`/blog?tag=${encodeURIComponent(tag)}`}
- className="border-border bg-primary/5 hover:bg-primary/10 rounded-full border px-2.5 py-0.5 transition-colors"
- >
+ <div className="flex flex-wrap gap-1 items-center justify-center">
+ {tags.map((tag) => (
+ <Link
+ key={tag}
+ href={`/blog?tag=${encodeURIComponent(tag)}`}
+
+ >
+ <Badge variant="secondary" className="border border-border text-xs">
{tag}
- </Link>
- ))}
- </div>
- </>
+ </Badge>
+ </Link>
+ ))}
+ </div>
)
)
})()}
@@ -247,6 +249,7 @@ export default async function BlogPage({ params }: PageProps) {
</div>
</div>
</article>
+ <MobileTOC />
</div>
</>
)
diff --git a/apps/www/app/(blog)/blog/page.tsx b/apps/www/app/(blog)/blog/page.tsx
index f1d03dec..bcef6484 100644
--- a/apps/www/app/(blog)/blog/page.tsx
+++ b/apps/www/app/(blog)/blog/page.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @next/next/no-img-element */
import type { Metadata } from "next"
import Link from "next/link"
import type { Blog, BreadcrumbList, WithContext } from "schema-dts"
@@ -12,6 +13,7 @@ import {
normalizeTag,
pluralize,
} from "@/lib/utils"
+import { Badge } from "@/components/ui/badge"
export const revalidate = false
export const dynamic = "force-static"
@@ -43,8 +45,6 @@ export default async function Page({
return dateB - dateA
})
- const allTags = posts.flatMap((p) => normalizeTag(p.data?.tags))
- const tags = [...new Set(allTags)].filter(Boolean).sort()
const filteredPosts = selectedTag
? posts.filter((p) => normalizeTag(p.data?.tags).includes(selectedTag))
: posts
@@ -127,21 +127,21 @@ export default async function Page({
__html: serializedBreadcrumbStructuredData,
}}
/>
- <main className="mx-auto w-full max-w-6xl px-6 py-8">
- <header className="mb-8 space-y-4">
+ <main className="container mx-auto py-10 md:py-14">
+ <header className="mb-12 space-y-3">
<div>
- <h1 className="text-3xl font-bold tracking-tight">Blog</h1>
+ <h1 className="text-3xl font-semibold tracking-tight">Blog</h1>
<p className="text-muted-foreground mt-2 text-lg">
{BLOG_DESCRIPTION}
</p>
</div>
{filteredPosts.length > 0 && (
- <p className="text-muted-foreground text-sm">
+ <Badge variant="default" className="text-xs shadow-none">
{selectedTag
? `${pluralize(filteredPosts.length, "article")} tagged with "${selectedTag}"`
: `${pluralize(filteredPosts.length, "article")} total`}
- </p>
+ </Badge>
)}
</header>
@@ -192,65 +192,64 @@ export default async function Page({
)}
</div>
) : (
- <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
+ <div className="grid gap-8 sm:grid-cols-2 lg:grid-cols-3">
{filteredPosts.map(async (post) => {
const content = await post.data?.getText("raw")
return (
<article
key={post.url}
- className="group bg-card hover:bg-accent/5 flex flex-col overflow-hidden rounded-xl border transition-all duration-200"
+ className="group flex flex-col rounded-lg border"
>
<Link href={post.url} className="flex h-full flex-col">
{post.data?.image && (
- <div className="aspect-video overflow-hidden">
+ <div className="border-b overflow-hidden rounded-t-lg">
<img
src={post.data.image}
alt={post.data?.title ?? post.url}
width={640}
height={360}
- className="h-full w-full object-cover"
+ className="w-full h-auto object-contain transition-transform duration-300 group-hover:scale-[1.02]"
/>
</div>
)}
- <div className="flex flex-1 flex-col space-y-4 p-6">
+ <div className="flex flex-1 flex-col space-y-3 p-6">
<div className="flex-1 space-y-2">
- <h2 className="group-hover:text-primary line-clamp-2 text-xl leading-tight font-semibold transition-colors">
+ <h2 className="group-hover:text-primary line-clamp-2 text-xl font-semibold leading-tight transition-colors">
{post.data?.title ?? post.url}
</h2>
{post.data?.description && (
- <p className="text-muted-foreground line-clamp-3 text-sm leading-relaxed">
+ <p className="text-muted-foreground line-clamp-2 text-sm leading-relaxed">
{post.data.description}
</p>
)}
</div>
- <div className="text-muted-foreground flex flex-col gap-2 text-xs">
- <div className="flex items-center gap-2">
- {post.data?.publishedOn && (
- <time dateTime={post.data.publishedOn}>
- {formatDate(post.data.publishedOn)}
- </time>
- )}
- {post.data?.publishedOn && <span>·</span>}
- <span>
- {calculateReadingTime(content ?? "")} min read
- </span>
- </div>
-
- {normalizeTag(post.data?.tags).length > 0 && (
- <div className="flex flex-wrap gap-1">
- {normalizeTag(post.data.tags).map((tag) => (
- <span
- key={tag}
- className="bg-muted/50 rounded-md border px-2 py-1 text-xs"
- >
- {tag}
- </span>
- ))}
- </div>
+ <div className="text-muted-foreground flex items-center gap-2 text-xs">
+ {post.data?.publishedOn && (
+ <time dateTime={post.data.publishedOn}>
+ {formatDate(post.data.publishedOn)}
+ </time>
)}
+ {post.data?.publishedOn && <span>·</span>}
+ <span>
+ {calculateReadingTime(content ?? "")} min read
+ </span>
</div>
+
+ {normalizeTag(post.data?.tags).length > 0 && (
+ <div className="flex flex-wrap gap-1.5">
+ {normalizeTag(post.data.tags).slice(0, 3).map((tag) => (
+ <Badge
+ key={tag}
+ variant="secondary"
+ className="border border-border text-xs"
+ >
+ {tag}
+ </Badge>
+ ))}
+ </div>
+ )}
</div>
</Link>
</article>
diff --git a/apps/www/components/blog/mobile-toc.tsx b/apps/www/components/blog/mobile-toc.tsx
new file mode 100644
index 00000000..ac10f666
--- /dev/null
+++ b/apps/www/components/blog/mobile-toc.tsx
@@ -0,0 +1,52 @@
+"use client"
+
+import { useState } from "react"
+import { Menu } from "lucide-react"
+
+import { Button } from "@/components/ui/button"
+import {
+ Sheet,
+ SheetContent,
+ SheetHeader,
+ SheetTitle,
+ SheetTrigger,
+} from "@/components/ui/sheet"
+
+import { BlogTableOfContents } from "./table-of-contents"
+
+export function MobileTOC() {
+ const [open, setOpen] = useState(false)
+
+ return (
+ <div className="fixed right-8 bottom-8 z-50 lg:hidden">
+ <Sheet open={open} onOpenChange={setOpen}>
+ <SheetTrigger asChild>
+ <Button
+ size="icon"
+ className="bg-primary text-primary-foreground size-12 rounded-full shadow-lg transition-all duration-200 hover:scale-105 hover:shadow-xl"
+ aria-label="Table of contents"
+ >
+ <Menu className="size-5" />
+ <span className="sr-only">Table of contents</span>
+ </Button>
+ </SheetTrigger>
+ <SheetContent
+ side="bottom"
+ className="border-border bg-background/60 right-4! bottom-4! left-4! h-fit max-h-[60vh] overflow-hidden rounded-2xl border p-0 shadow-2xl backdrop-blur-xl"
+ >
+ <SheetHeader className="bg-muted border-border border-b px-6 py-3">
+ <SheetTitle className="item-start flex text-left font-semibold">
+ On this page
+ </SheetTitle>
+ </SheetHeader>
+ <div className="bg-card max-h-[calc(60vh-8rem)] overflow-y-auto p-6 pt-4">
+ <BlogTableOfContents
+ className="[&_a:hover]:bg-muted/50 p-0 [&_a]:transition-colors [&_nav]:space-y-2 [&>p]:hidden"
+ onLinkClick={() => setOpen(false)}
+ />
+ </div>
+ </SheetContent>
+ </Sheet>
+ </div>
+ )
+}
diff --git a/apps/www/components/blog/table-of-contents.tsx b/apps/www/components/blog/table-of-contents.tsx
index 6e5be8ef..557b1e62 100644
--- a/apps/www/components/blog/table-of-contents.tsx
+++ b/apps/www/components/blog/table-of-contents.tsx
@@ -16,7 +16,13 @@ const generateHeadingId = (text: string) => {
.trim()
}
-export function BlogTableOfContents({ className }: { className?: string }) {
+export function BlogTableOfContents({
+ className,
+ onLinkClick,
+}: {
+ className?: string
+ onLinkClick?: () => void
+}) {
const [activeHeading, setActiveHeading] = useState<string>("")
const [headings, setHeadings] = useState<string[]>([])
const [isLoading, setIsLoading] = useState(true)
@@ -85,6 +91,7 @@ export function BlogTableOfContents({ className }: { className?: string }) {
const handleClick = (headingId: string) => {
setActiveHeading(headingId)
+ onLinkClick?.()
}
return (
diff --git a/apps/www/content/blog/nextjs-website-template.mdx b/apps/www/content/blog/nextjs-website-template.mdx
index be5a09ef..ff3622d5 100644
--- a/apps/www/content/blog/nextjs-website-template.mdx
+++ b/apps/www/content/blog/nextjs-website-template.mdx
@@ -123,15 +123,17 @@ Your template will almost certainly come with a file called something like `.env
For an e-commerce site using Stripe and a headless CMS, for instance, your `.env.local` file would end up looking something like this:
-# Stripe API Keys
+### Stripe API Keys
-NEXT*PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test*...
-STRIPE*SECRET_KEY=sk_test*...
+`NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...`
-# Headless CMS Config
+`STRIPE_SECRET_KEY=sk_test_...`
-CMS_API_URL=https://your-cms.com/graphql
-CMS_PREVIEW_SECRET=a_very_secret_token
+### Headless CMS Config
+
+`CMS_API_URL=https://your-cms.com/graphql`
+
+`CMS_PREVIEW_SECRET=a_very_secret_token`
Getting these values right is non-negotiable. If they're missing or incorrect, your app simply won't work as expected.
diff --git a/apps/www/content/blog/typescript-vs-javascript-differences.mdx b/apps/www/content/blog/typescript-vs-javascript-differences.mdx
index 7ee14401..04ecda5d 100644
--- a/apps/www/content/blog/typescript-vs-javascript-differences.mdx
+++ b/apps/www/content/blog/typescript-vs-javascript-differences.mdx
@@ -36,62 +36,62 @@ According to GitHub's Octoverse 2025 report, TypeScript's usage exploded with a
This comparison isn't about crowning a winner. It’s about helping you make the right call for your project's unique needs. The table below breaks down the key trade-offs at a glance.
-<div className="overflow-x-auto">
- <table className="min-w-full divide-y divide-gray-200">
- <thead className="bg-gray-50">
- <tr>
+<div className="my-6 w-full overflow-x-auto rounded-lg border">
+ <table className="relative w-full text-sm">
+ <thead className="bg-muted border-b">
+ <tr className="m-0 border-b transition-colors hover:bg-muted/50">
<th
scope="col"
- className="px-6 py-3 text-left text-xs font-medium tracking-wider text-gray-500 uppercase"
+ className="min-w-[120px] px-4 py-3 text-left font-semibold"
>
Consideration
</th>
<th
scope="col"
- className="px-6 py-3 text-left text-xs font-medium tracking-wider text-gray-500 uppercase"
+ className="min-w-[200px] px-4 py-3 text-left font-semibold"
>
JavaScript (Dynamic Flexibility)
</th>
<th
scope="col"
- className="px-6 py-3 text-left text-xs font-medium tracking-wider text-gray-500 uppercase"
+ className="min-w-[200px] px-4 py-3 text-left font-semibold"
>
TypeScript (Structured Safety)
</th>
</tr>
</thead>
- <tbody className="divide-y divide-gray-200 bg-white">
- <tr>
- <td className="px-6 py-4 text-sm font-medium whitespace-nowrap text-gray-900">
+ <tbody>
+ <tr className="m-0 border-b transition-colors hover:bg-muted/50">
+ <td className="min-w-[120px] px-4 py-3 text-left font-medium">
Project Scope
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Ideal for small projects, scripts, and rapid prototypes.
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Better for large, complex applications requiring long-term
maintainability.
</td>
</tr>
- <tr>
- <td className="px-6 py-4 text-sm font-medium whitespace-nowrap text-gray-900">
+ <tr className="m-0 border-b transition-colors hover:bg-muted/50">
+ <td className="min-w-[120px] px-4 py-3 text-left font-medium">
Error Detection
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Errors are found at runtime, which can impact users.
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Catches type-related errors during compilation, before code is run.
</td>
</tr>
- <tr>
- <td className="px-6 py-4 text-sm font-medium whitespace-nowrap text-gray-900">
+ <tr className="m-0 border-b transition-colors hover:bg-muted/50 last:border-b-0">
+ <td className="min-w-[120px] px-4 py-3 text-left font-medium">
Developer Experience
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Simple setup with no compilation step, allowing for faster iteration.
</td>
- <td className="px-6 py-4 text-sm whitespace-nowrap text-gray-500">
+ <td className="min-w-[200px] px-4 py-3 text-left">
Superior tooling, autocompletion, and safer code refactoring.
</td>
</tr>
diff --git a/apps/www/mdx-components.tsx b/apps/www/mdx-components.tsx
index 4fa8b5b2..35f658e7 100644
--- a/apps/www/mdx-components.tsx
+++ b/apps/www/mdx-components.tsx
@@ -50,7 +50,7 @@ export const mdxComponents = {
.replace(/\?/g, "")
.toLowerCase()}
className={cn(
- "font-heading mt-8 scroll-m-28 text-xl font-medium tracking-tight first:mt-0 lg:mt-8 [&+p]:!mt-4 *:[code]:text-xl",
+ "font-heading mt-8 scroll-m-28 text-xl font-medium tracking-tight first:mt-0 lg:mt-8 [&+p]:mt-4! *:[code]:text-xl",
className
)}
{...props}
@@ -101,7 +101,7 @@ export const mdxComponents = {
),
p: ({ className, ...props }: React.ComponentProps<"p">) => (
<p
- className={cn("leading-relaxed [&:not(:first-child)]:mt-6", className)}
+ className={cn("leading-relaxed not-first:mt-6", className)}
{...props}
/>
),
@@ -119,7 +119,7 @@ export const mdxComponents = {
),
blockquote: ({ className, ...props }: React.ComponentProps<"blockquote">) => (
<blockquote
- className={cn("mt-6 border-l-2 pl-6 italic", className)}
+ className={cn("mt-6 border-l-2 pl-6 pr-4 italic bg-muted/50 py-4 rounded-r-md", className)}
{...props}
/>
),
@@ -127,30 +127,50 @@ export const mdxComponents = {
// eslint-disable-next-line @next/next/no-img-element
<img className={cn("rounded-md", className)} alt={alt} {...props} />
),
- hr: ({ ...props }: React.ComponentProps<"hr">) => (
- <hr className="my-4 md:my-8" {...props} />
+ iframe: ({ className, ...props }: React.ComponentProps<"iframe">) => (
+ <iframe
+ className={cn("mt-6 rounded-md w-full", className)}
+ {...props}
+ />
+ ),
+ hr: ({ className, ...props }: React.ComponentProps<"hr">) => (
+ <div className={cn("my-4 flex items-center justify-center md:my-8", className)}>
+ <hr
+ className="mx-4 h-px w-full border-0 bg-linear-to-r from-transparent via-border to-transparent"
+ {...props}
+ />
+ </div>
),
table: ({ className, ...props }: React.ComponentProps<"table">) => (
- <div className="my-6 w-full overflow-y-auto">
+ <div className="my-6 w-full overflow-x-auto rounded-lg border">
<table
className={cn(
- "relative w-full overflow-hidden border-none text-sm",
+ "relative w-full text-sm",
className
)}
{...props}
/>
</div>
),
+ thead: ({ className, ...props }: React.ComponentProps<"thead">) => (
+ <thead
+ className={cn("bg-muted border-b", className)}
+ {...props}
+ />
+ ),
tr: ({ className, ...props }: React.ComponentProps<"tr">) => (
<tr
- className={cn("last:border-b-none m-0 border-b", className)}
+ className={cn(
+ "m-0 border-b transition-colors hover:bg-muted/50 last:border-b-0",
+ className
+ )}
{...props}
/>
),
th: ({ className, ...props }: React.ComponentProps<"th">) => (
<th
className={cn(
- "px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
+ "min-w-[120px] px-4 py-3 text-left font-semibold [[align=center]]:text-center [[align=right]]:text-right",
className
)}
{...props}
@@ -159,7 +179,7 @@ export const mdxComponents = {
td: ({ className, ...props }: React.ComponentProps<"td">) => (
<td
className={cn(
- "px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
+ "min-w-[120px] px-4 py-3 text-left [[align=center]]:text-center [[align=right]]:text-right",
className
)}
{...props}
@@ -169,7 +189,7 @@ export const mdxComponents = {
return (
<pre
className={cn(
- "no-scrollbar min-w-0 overflow-x-auto px-4 py-3.5 outline-none has-[[data-highlighted-line]]:px-0 has-[[data-line-numbers]]:px-0 has-[[data-slot=tabs]]:p-0",
+ "no-scrollbar min-w-0 overflow-x-auto px-4 py-3.5 outline-none has-data-highlighted-line:px-0 has-data-line-numbers:px-0 has-data-[slot=tabs]:p-0",
className
)}
{...props}
@@ -226,7 +246,7 @@ export const mdxComponents = {
return (
<code
className={cn(
- "bg-muted relative rounded-md px-[0.3rem] py-[0.2rem] font-mono text-[0.8rem] break-words outline-none",
+ "bg-muted relative rounded-md px-[0.3rem] py-[0.2rem] font-mono text-[0.8rem] wrap-break-word outline-none",
className
)}
{...props}
diff --git a/apps/www/styles/globals.css b/apps/www/styles/globals.css
index cf0e067e..f6a513e8 100644
--- a/apps/www/styles/globals.css
+++ b/apps/www/styles/globals.css
@@ -516,7 +516,7 @@
background-color: var(--color-code);
color: var(--color-code-foreground);
border-radius: var(--radius-lg);
- border-width: 0px;
+ border-width: 1px;
border-color: var(--border);
margin-top: calc(var(--spacing) * 6);
overflow: hidden;
@@ -615,4 +615,8 @@
font-family: var(--font-mono);
font-size: 0.8rem;
}
+
+ iframe {
+ @apply mt-6 rounded-lg overflow-hidden;
+ }
}