Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improved blog layout

Steven Teydf09150f7c4d
diff --git a/app/dub.co/blog/category/[slug]/page.tsx b/app/dub.co/blog/(index)/category/[slug]/page.tsx
similarity index 100%
rename from app/dub.co/blog/category/[slug]/page.tsx
rename to app/dub.co/blog/(index)/category/[slug]/page.tsx
diff --git a/app/dub.co/blog/layout.tsx b/app/dub.co/blog/(index)/layout.tsx
similarity index 100%
rename from app/dub.co/blog/layout.tsx
rename to app/dub.co/blog/(index)/layout.tsx
diff --git a/app/dub.co/blog/page.tsx b/app/dub.co/blog/(index)/page.tsx
similarity index 100%
rename from app/dub.co/blog/page.tsx
rename to app/dub.co/blog/(index)/page.tsx
diff --git a/app/dub.co/(blog-post)/blog/[slug]/page.tsx b/app/dub.co/blog/(post)/[slug]/page.tsx
similarity index 100%
rename from app/dub.co/(blog-post)/blog/[slug]/page.tsx
rename to app/dub.co/blog/(post)/[slug]/page.tsx
diff --git a/app/ui/content/blog-layout-hero.tsx b/app/ui/content/blog-layout-hero.tsx
index bfa43a918c..5e8fb49cf5 100644
--- a/app/ui/content/blog-layout-hero.tsx
+++ b/app/ui/content/blog-layout-hero.tsx
@@ -1,10 +1,11 @@
"use client";
import { BLOG_CATEGORIES } from "#/lib/constants/content";
-import { cn } from "#/lib/utils";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
import Link from "next/link";
import { useParams } from "next/navigation";
+import { motion } from "framer-motion";
+import { cn } from "#/lib/utils";
export default function BlogLayoutHero() {
const { slug } = useParams() as { slug?: string };
@@ -20,8 +21,8 @@ export default function BlogLayoutHero() {
<p className="mt-4 text-xl text-gray-500">
{data?.description || "Latest news and updates from Dub."}
</p>
- <div className="mt-6 flex items-center space-x-4">
- <CategoryLink title="All" href="/blog" active={!slug} />
+ <nav className="mt-6 flex w-fit items-center space-x-2 rounded-full border border-gray-200 bg-white p-2">
+ <CategoryLink title="Overview" href="/blog" active={!slug} />
{BLOG_CATEGORIES.map((category) => (
<CategoryLink
key={category.slug}
@@ -30,13 +31,9 @@ export default function BlogLayoutHero() {
active={category.slug === slug}
/>
))}
- <CategoryLink
- title="Customer Stories"
- href="/customers"
- active={false}
- />
- <CategoryLink title="Changelog" href="/changelog" active={false} />
- </div>
+ <CategoryLink title="Customer Stories" href="/customers" />
+ <CategoryLink title="Changelog" href="/changelog" />
+ </nav>
</div>
</MaxWidthWrapper>
);
@@ -49,18 +46,25 @@ const CategoryLink = ({
}: {
title: string;
href: string;
- active: boolean;
+ active?: boolean;
}) => {
return (
- <Link
- href={href}
- className={cn("border-b-2 border-transparent py-1", {
- "border-black text-black": active,
- })}
- >
- <div className="rounded-md px-3 py-2 text-sm text-gray-600 transition-all hover:bg-gray-100 active:bg-gray-200">
+ <Link href={href} className="relative z-10">
+ <div
+ className={cn(
+ "rounded-full px-4 py-2 text-sm text-gray-600 transition-all",
+ active ? "text-white" : "hover:bg-gray-100 active:bg-gray-200",
+ )}
+ >
{title}
</div>
+ {active && (
+ <motion.div
+ layoutId="indicator"
+ className="absolute left-0 top-0 h-full w-full rounded-full bg-gradient-to-tr from-gray-800 via-gray-700 to-gray-800"
+ style={{ zIndex: -1 }}
+ />
+ )}
</Link>
);
};