Commit 18817cb2 by PLN (Algolia)

projects: card components, timeline index, first-class bilingual detail pages

ProjectCard (fixed anatomy: accent bar, title+status, tagline, meta,
links), StatusBadge, ProjectLinks (typed slots, host annotation instead
of logo maintenance). /projects renders as a year-banded timeline with
tag chips; /projects/[slug] and /projects/[slug]/[lang] are first-class
static pages with OG metadata, language switcher and the honest
untranslated banner — same shapes as blog.
parent afeadf11
import { notFound } from 'next/navigation';
import ProjectPage from '@/components/projects/ProjectPage';
import { PROJECT_LANGS, getAllProjectSlugs, getProject, getProjectLanguages, projectOgImage } from '@/lib/projects';
export function generateStaticParams() {
const params = getAllProjectSlugs()
.flatMap((slug) =>
PROJECT_LANGS.filter((lang) => lang !== 'en').map((lang) => ({ slug, lang })),
)
.filter(({ slug, lang }) => getProjectLanguages(slug).includes(lang));
// Static export needs at least one prerendered variant per dynamic route;
// with no published projects in prod, emit a 404 sentinel so the export
// still ships.
return params.length > 0 ? params : [{ slug: '-', lang: 'fr' }];
}
export async function generateMetadata({ params }) {
const { slug, lang } = await params;
const project = await getProject(slug, lang).catch(() => null);
if (!project) return {};
const canonical = `https://me.nech.pl/projects/${slug}/${lang}`;
const image = projectOgImage(slug);
return {
title: project.title,
description: project.description,
alternates: { canonical },
openGraph: {
title: project.title,
description: project.description,
type: 'article',
url: canonical,
publishedTime: project.date,
images: image ? [image] : undefined,
},
};
}
export default async function ProjectInLang({ params }) {
const { slug, lang } = await params;
if (lang === 'en' || !PROJECT_LANGS.includes(lang)) notFound();
const project = await getProject(slug, lang).catch(() => null);
if (!project) notFound();
return <ProjectPage project={project} />;
}
import { notFound } from 'next/navigation';
import ProjectPage from '@/components/projects/ProjectPage';
import { DEFAULT_LANG, getAllProjectSlugs, getProject, projectOgImage } from '@/lib/projects';
export function generateStaticParams() {
const slugs = getAllProjectSlugs();
return slugs.length > 0 ? slugs.map((slug) => ({ slug })) : [{ slug: '-' }];
}
export async function generateMetadata({ params }) {
const { slug } = await params;
const project = await getProject(slug).catch(() => null);
if (!project) return {};
const canonical = `https://me.nech.pl/projects/${slug}`;
const image = projectOgImage(slug);
return {
title: project.title,
description: project.description,
alternates: { canonical },
openGraph: {
title: project.title,
description: project.description,
type: 'article',
url: canonical,
publishedTime: project.date,
images: image ? [image] : undefined,
},
twitter: {
card: image ? 'summary_large_image' : 'summary',
title: project.title,
description: project.description,
images: image ? [image.url] : undefined,
},
};
}
export default async function Project({ params }) {
const { slug } = await params;
const project = await getProject(slug, DEFAULT_LANG).catch(() => null);
if (!project) notFound();
return <ProjectPage project={project} />;
}
import Layout from '@/components/layout';
import ProjectCard from '@/components/projects/ProjectCard';
import { getProjects, getProjectTags } from '@/lib/projects';
export const metadata = {
title: { absolute: 'Projects | PLN' },
description: 'Tools and experiments, newest first',
};
/** The gallery as a timeline (owner note on route-shape, 2026-11-06):
* year bands, newest first, tags as muted chips — functional MVP, no filter
* JS; the dimensions can grow into facets later without moving the data. */
export default function Projects() {
const projects = getProjects();
const tags = getProjectTags();
const years = [...new Set(projects.map((p) => (p.date ? p.date.slice(0, 4) : 'undated')))];
return (
<Layout>
<div className="max-w-4xl mx-auto">
<section className="mb-10">
<h1 className="text-3xl font-semibold text-[var(--text-primary)]">Projects</h1>
<p className="mt-2 text-[var(--text-muted)]">
Tools and experiments, newest first.
</p>
{tags.length > 0 && (
<p className="mt-3 flex flex-wrap gap-2">
{tags.map(({ tag, count }) => (
<span
key={tag}
className="rounded-full border border-[var(--border)] px-2.5 py-0.5 text-xs text-[var(--text-muted)]"
>
{tag} <span className="opacity-60">{count}</span>
</span>
))}
</p>
)}
</section>
{years.map((year) => (
<section key={year} className="mb-10">
<h2 className="text-sm font-medium tracking-wide text-[var(--text-muted)] uppercase mb-3">
{year}
</h2>
<ul className="grid gap-4 sm:grid-cols-2 list-none p-0">
{projects
.filter((p) => (p.date ? p.date.slice(0, 4) : 'undated') === year)
.map((project) => (
<li key={project.slug}>
<ProjectCard project={project} />
</li>
))}
</ul>
</section>
))}
</div>
</Layout>
);
}
import Link from 'next/link';
import Date from '@/components/date';
import StatusBadge from './StatusBadge';
import { getProjectLinks } from '@/lib/projects';
/** Fixed card anatomy (decided: defaults-escape A) — media / title+status /
* tagline / meta / links. The accent token is the only per-project visual
* variable; escapes are content, never per-project code. */
export default function ProjectCard({ project }) {
const links = getProjectLinks(project);
const accent = project.accent || 'var(--link)';
return (
<Link
href={`/projects/${project.slug}`}
style={{ '--project-accent': accent }}
className="group relative block rounded-xl border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--surface-raised)] transition-colors overflow-hidden"
>
<span
aria-hidden
className="absolute inset-x-0 top-0 h-[3px] bg-[var(--project-accent)] opacity-80"
/>
{project.image && (
<img
src={project.image}
alt=""
className="w-full aspect-[1200/630] object-cover"
loading="lazy"
/>
)}
<span className="block p-4">
<span className="flex items-baseline justify-between gap-3">
<span className="font-medium text-[var(--text-primary)] text-balance">
{project.title}
</span>
<StatusBadge status={project.status} />
</span>
{project.tagline && (
<span className="block mt-1 text-sm text-[var(--text-muted)] line-clamp-2">
{project.tagline}
</span>
)}
<span className="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-[var(--text-muted)]">
{project.date && <Date dateString={project.date} />}
{(project.tags ?? []).map((tag) => (
<span key={tag} className="rounded-full border border-[var(--border)] px-2 py-0.5">
{tag}
</span>
))}
</span>
{links.length > 0 && (
<span className="mt-2 flex flex-wrap gap-x-3 text-xs text-[var(--text-muted)]">
{links.map((link) => (
<span key={link.key}>{link.label}</span>
))}
</span>
)}
</span>
</Link>
);
}
import Link from 'next/link';
/** Typed link slots — regular button row, only-when-exists (decided:
* link-taxonomy A). `post` slots resolve to internal /blog/<slug> routes;
* the host annotation tells GitHub from GitLab from anywhere else without
* a single logo to maintain. */
export default function ProjectLinks({ links, className = '' }) {
if (!links?.length) return null;
return (
<div className={`flex flex-wrap gap-2 ${className}`}>
{links.map((link) =>
link.url.startsWith('/') ? (
<Link
key={link.key}
href={link.url}
className="inline-flex items-baseline gap-1.5 rounded-lg border border-[var(--border)] px-3 py-1.5 text-sm text-[var(--text-primary)] hover:bg-[var(--surface-raised)] transition-colors"
>
{link.label}
</Link>
) : (
<a
key={link.key}
href={link.url}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-baseline gap-1.5 rounded-lg border border-[var(--border)] px-3 py-1.5 text-sm text-[var(--text-primary)] hover:bg-[var(--surface-raised)] transition-colors"
>
{link.label}
{link.host && <span className="text-xs text-[var(--text-muted)]">{link.host}</span>}
</a>
)
)}
</div>
);
}
import Link from 'next/link';
import Layout from '@/components/layout';
import Date from '@/components/date';
import StatusBadge from './StatusBadge';
import ProjectLinks from './ProjectLinks';
import utilStyles from '@/styles/utils.module.css';
import blogStyles from '@/app/blog/blog.module.css';
/** Shared detail renderer for /projects/[slug] and /projects/[slug]/[lang].
* Hero (accent bar, title, tagline, status, typed links) over the bilingual
* body in the site's canonical prose styling. */
export default function ProjectPage({ project }) {
const accent = project.accent || 'var(--link)';
return (
<Layout>
<Link href="/projects" className={utilStyles.backLink}>
← All projects
</Link>
<article style={{ '--project-accent': accent }}>
<header className="border-l-2 border-[var(--project-accent)] pl-4 mb-8">
<h1 className={utilStyles.headingXl}>{project.title}</h1>
{project.tagline && (
<p className="mt-2 text-lg text-[var(--text-muted)] text-balance">{project.tagline}</p>
)}
<div className="mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-[var(--text-muted)]">
<StatusBadge status={project.status} />
{project.date && <Date dateString={project.date} />}
{(project.tags ?? []).map((tag) => (
<span key={tag} className="rounded-full border border-[var(--border)] px-2 py-0.5 text-xs">
{tag}
</span>
))}
</div>
<ProjectLinks links={project.links} className="mt-4" />
{project.languages.length > 1 && (
<p className="mt-3 text-sm">
{project.languages.map((lang, i) => (
<span key={lang}>
{i > 0 && ' · '}
{lang === project.lang ? (
<span className="text-[var(--text-muted)]">{lang.toUpperCase()}</span>
) : (
<Link href={`/projects/${project.slug}/${lang}`} className={utilStyles.inlineLink}>
{lang.toUpperCase()}
</Link>
)}
</span>
))}
</p>
)}
{project.untranslated && (
<p className="mt-3 rounded-lg border border-[var(--border)] bg-[var(--surface-raised)] px-3 py-2 text-sm text-[var(--text-muted)]">
This page isn&apos;t translated to {project.untranslated.toUpperCase()} yet — showing{' '}
{project.lang.toUpperCase()} instead.
</p>
)}
</header>
{project.contentHtml ? (
<div
className={blogStyles.prose}
data-prose
dangerouslySetInnerHTML={{ __html: project.contentHtml }}
/>
) : null}
</article>
</Layout>
);
}
const STATUS_COLOR = {
active: '#2e9e44',
beta: '#d08700',
archived: 'var(--text-muted)',
};
/** Status chip — a dot and the word, honest in light and dark. */
export default function StatusBadge({ status }) {
const color = STATUS_COLOR[status] ?? STATUS_COLOR.active;
return (
<span className="inline-flex items-center gap-1.5 text-xs text-[var(--text-muted)] whitespace-nowrap">
<span
aria-hidden
className="inline-block w-2 h-2 rounded-full"
style={{ backgroundColor: color }}
/>
{status}
</span>
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment