fix: ajouter des titres HTML pertinents aux pages sujets et personnalités
Les pages /s, /p, /s/[slug] et /p/[slug] utilisaient le titre générique du layout. Chaque page a maintenant un titre spécifique via metadata ou generateMetadata.
This commit is contained in:
parent
a07200f8cf
commit
785aaaf615
4 changed files with 38 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { Effect } from 'effect'
|
||||
|
|
@ -14,6 +15,19 @@ interface PageProps {
|
|||
params: Promise<{ slug: string }>
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { slug } = await params
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
const publicFigureRepo = createPublicFigureRepository(supabase)
|
||||
const figure = await Effect.runPromise(publicFigureRepo.findBySlug(slug))
|
||||
if (!figure) return { title: 'Personnalité introuvable - Débats.co' }
|
||||
return { title: `${figure.name} - Débats.co` }
|
||||
} catch {
|
||||
return { title: 'Personnalité - Débats.co' }
|
||||
}
|
||||
}
|
||||
|
||||
function groupBySubject(statements: StatementWithDetails[]) {
|
||||
return statements.reduce(
|
||||
(acc, { statement, position, subject }) => {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
import { Effect } from 'effect'
|
||||
import { createServerSupabaseClient } from '../../infra/supabase/ssr'
|
||||
|
|
@ -7,6 +8,10 @@ import ContentWithSidebar from '../../components/layout/ContentWithSidebar'
|
|||
import ErrorDisplay from '../../components/layout/ErrorDisplay'
|
||||
import styles from './personalities.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Personnalités - Débats.co',
|
||||
}
|
||||
|
||||
export default async function PersonalitiesPage() {
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { Effect } from 'effect'
|
||||
|
|
@ -14,6 +15,19 @@ interface PageProps {
|
|||
params: Promise<{ slug: string }>
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { slug } = await params
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
const subjectRepo = createSubjectRepository(supabase)
|
||||
const subject = await Effect.runPromise(subjectRepo.findBySlug(slug))
|
||||
if (!subject) return { title: 'Sujet introuvable - Débats.co' }
|
||||
return { title: `${subject.title} - Débats.co` }
|
||||
} catch {
|
||||
return { title: 'Sujet - Débats.co' }
|
||||
}
|
||||
}
|
||||
|
||||
function groupByPosition(statements: StatementWithFigure[]) {
|
||||
return statements.reduce(
|
||||
(acc, { statement, position, publicFigure }) => {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { Metadata } from 'next'
|
||||
import Link from 'next/link'
|
||||
import { Effect } from 'effect'
|
||||
import { createServerSupabaseClient } from '../../infra/supabase/ssr'
|
||||
|
|
@ -8,6 +9,10 @@ import SubjectCounters from '../../components/subjects/SubjectCounters'
|
|||
import SubjectTitle from '../../components/subjects/SubjectTitle'
|
||||
import styles from './subjects.module.css'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Sujets - Débats.co',
|
||||
}
|
||||
|
||||
export default async function SubjectsPage() {
|
||||
try {
|
||||
const supabase = await createServerSupabaseClient()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue