Skip to content

Commit

Permalink
add "all" tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahor committed Apr 30, 2024
1 parent c0ec500 commit c08b86d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const getAllTags = (): MetadataRoute.Sitemap => {
const allTags = Array.from(
new Set(allPosts.flatMap((post) => post.fullTags)),
);
allTags.push("all");
return allTags.map((tag) => ({
url: `${BASE_URL}/tag/${tag}`,
lastModified: env.BUILD_TIME,
Expand Down
13 changes: 10 additions & 3 deletions src/app/tag/[tag]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { fr } from "date-fns/locale";
import Link from "next/link";
import { notFound } from "next/navigation";

const ALL_TAG = "all";

const allTags = Array.from(
new Set(allPosts.flatMap((post) => post.fullTags)),
).toSorted((a, b) => b.localeCompare(a));
allTags.unshift(ALL_TAG);

export const generateStaticParams = async () => {
return allTags.map((tag) => ({ tag }));
Expand All @@ -21,7 +24,9 @@ export default function TagPage({ params }: PageProps) {
if (!allTags.includes(params.tag)) notFound();

const filteredPosts = allPosts
.filter((post) => post.fullTags.includes(params.tag))
.filter(
(post) => params.tag === ALL_TAG || post.fullTags.includes(params.tag),
)
.toSorted((a, b) => b.datePublished.localeCompare(a.datePublished));

return (
Expand All @@ -30,7 +35,7 @@ export default function TagPage({ params }: PageProps) {
{allTags.map((tag) => {
const active = tag === params.tag;
return (
<Link key={tag} href={`/tag/${tag}`} className="w-full md:w-max ">
<Link key={tag} href={`/tag/${tag}`} className="w-full md:w-max">
<Button
disabled={active}
className="capitalize w-full justify-start"
Expand All @@ -43,7 +48,9 @@ export default function TagPage({ params }: PageProps) {
})}
</nav>

<main className="col-span-4 md:col-span-3">
<hr className="col-span-4 md:hidden" />

<main className="col-span-4 md:col-span-3 px-4 md:px-0">
<h1 className="text-3xl font-semibold text-black dark:text-white capitalize">
{params.tag}
</h1>
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ThemeSwitcher } from "./theme-switcher";

export function Header() {
return (
<header className="py-4 sm:py-8 px-8 max-w-screen-xl mx-auto flex items-center justify-between">
<header className="py-4 sm:py-8 px-8 sm:px-12 max-w-screen-xl mx-auto flex items-center justify-between">
<Logo />
<div className="flex justify-end gap-3 items-center">
<nav className="flex gap-6">
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function Logo() {
src={mounted && theme === "dark" ? darkLogo : whiteLogo}
alt="Logo"
width={24}
className="transform hover:rotate-12 transition-transform -ml-2 w-[24px] h-[24px]"
className="transform hover:rotate-12 transition-transform w-[24px] h-[24px]"
/>
<span className="hidden sm:inline text-dark dark:text-white font-semibold text-lg">
Vahor
Expand Down
8 changes: 2 additions & 6 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export const AVATAR_URL = "https://avatars.githubusercontent.com/u/17593209";

export const HEADER_LINKS = [
{
label: "Accueil",
href: "/",
},
{
label: "Presentation",
href: "/about",
label: "Blog",
href: "/tag/all",
},
];
7 changes: 0 additions & 7 deletions src/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ const search_content = [
pageType: "app",
external: false,
})),
{
title: "Liste des articles",
datePublished: env.NEXT_PUBLIC_BUILD_TIME,
url: "/tag/project",
pageType: "app",
external: false,
},
...contact_links.map((l) => ({
title: l.label,
datePublished: env.NEXT_PUBLIC_BUILD_TIME,
Expand Down
9 changes: 8 additions & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ const config = {
center: true,
padding: {
DEFAULT: "1rem",
md: "4rem",
sm: "2rem",
lg: "4rem",
},
screens: {
sm: "640px",
md: "768px",
lg: "1024px",
xl: "1280px",
},
},
fontFamily: {
Expand Down

0 comments on commit c08b86d

Please sign in to comment.