Give projects and members their own pages
The API has always served a project's and a member's detail, with `path` and `alternates` in three languages, and the site had nowhere to show it. A project now has its page — tagline, status, technologies, description, technical decisions, what was learned, gallery, client, dates, lead, team, repositories and open calls — and so does a member: headline, bio, links, technologies and projects. Cards on the landing link to both. Addresses follow the API's rule read backwards (core/routes.ts): pages at the root, records under a section named in their language, the default language unprefixed. One catch-all route serves them all. Not a route per shape: Analog registers each loader as an internal Nitro route, and Nitro's router cannot hold `/:prefix/:slug` beside `/:prefix/:section/:slug` — the first became unreachable. The frame around a record (header, footer, lights, 404/503, title, description, canonical, hreflang) is one component now, PageShell, and each type only brings its body, all sharing one layout partial. Also fixes chips that stepped down one row after the first, on the landing's cards too: @pi/ui's reset gives every `li + li` a top margin, right for prose and wrong for a row spaced by `gap`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
103
landing/src/app/ui/routed-page.ts
Normal file
103
landing/src/app/ui/routed-page.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
computed,
|
||||
input,
|
||||
} from '@angular/core';
|
||||
|
||||
import { copyFor } from '../core/copy';
|
||||
import type { RoutedPageData, RoutedRecord } from '../core/routed-page';
|
||||
import { ContentPage } from './content-page';
|
||||
import { MemberDetail } from './member-detail';
|
||||
import { PageShell, type PageSeo } from './page-shell';
|
||||
import { ProjectDetail } from './project-detail';
|
||||
|
||||
/**
|
||||
* A page reached by its address, whatever it holds: the shell around it, and
|
||||
* the body for its type inside.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-routed-page',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [ContentPage, MemberDetail, PageShell, ProjectDetail],
|
||||
template: `
|
||||
<app-page-shell [data]="data()" [seo]="seo()">
|
||||
@if (data().found; as found) {
|
||||
@switch (found.type) {
|
||||
@case ('page') {
|
||||
<app-content-page
|
||||
[page]="found.record"
|
||||
[pages]="data().pages"
|
||||
[copy]="copy()"
|
||||
[locale]="data().locale"
|
||||
/>
|
||||
}
|
||||
@case ('project') {
|
||||
<app-project-detail
|
||||
[project]="found.record"
|
||||
[copy]="copy()"
|
||||
[locale]="data().locale"
|
||||
/>
|
||||
}
|
||||
@case ('member') {
|
||||
<app-member-detail
|
||||
[member]="found.record"
|
||||
[copy]="copy()"
|
||||
[locale]="data().locale"
|
||||
/>
|
||||
}
|
||||
}
|
||||
}
|
||||
</app-page-shell>
|
||||
`,
|
||||
})
|
||||
export class RoutedPage {
|
||||
readonly data = input.required<RoutedPageData>();
|
||||
|
||||
protected readonly copy = computed(() => copyFor(this.data().locale));
|
||||
|
||||
protected readonly seo = computed(() => seoFor(this.data().found));
|
||||
}
|
||||
|
||||
/** What each type puts in the document head. Null when nothing was found. */
|
||||
export function seoFor(found: RoutedRecord | null): PageSeo | null {
|
||||
if (!found) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (found.type) {
|
||||
case 'page': {
|
||||
const page = found.record;
|
||||
|
||||
return {
|
||||
title: page.meta_title || `Pireon — ${page.title}`,
|
||||
description: page.meta_description || page.excerpt || '',
|
||||
path: page.path,
|
||||
alternates: page.alternates ?? {},
|
||||
type: 'article',
|
||||
};
|
||||
}
|
||||
case 'project': {
|
||||
const project = found.record;
|
||||
|
||||
return {
|
||||
title: project.meta_title || `Pireon — ${project.title}`,
|
||||
description: project.meta_description || project.tagline || '',
|
||||
path: project.path,
|
||||
alternates: project.alternates ?? {},
|
||||
type: 'article',
|
||||
};
|
||||
}
|
||||
case 'member': {
|
||||
const member = found.record;
|
||||
|
||||
return {
|
||||
title: `Pireon — ${member.name}`,
|
||||
description: member.headline || member.bio?.slice(0, 160) || '',
|
||||
path: member.path,
|
||||
alternates: member.alternates ?? {},
|
||||
type: 'profile',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user