mirror of
https://github.com/logos-co/logos-web.git
synced 2026-08-27 20:21:08 +00:00
Follow-up to the LPE→Blog rename: purge "Press" from code symbol and file names and make every consumer use ROUTES.blog instead of a hardcoded path. - ROUTES: key press -> blog (value /blog); all consumers use ROUTES.blog - Rename files: lib/press-engine.ts -> lib/blog-engine.ts (+ test), blog/_sections/press-atoms.tsx -> blog-atoms.tsx, home/press-section.tsx -> blog-section.tsx, public/images/press-engine/ -> public/images/blog-engine/ - Rename code symbols: PressArticleRow/PressPodcastRow/PressHero/PressCopy/ PressRowLink/PressSection/PressCard(Props)/PressPage, getLatest*Press*, getPressPageData, getPress*Image*, PRESS_ORIGIN/PRESS_HERO_IMAGE, pressT, etc. - Rename code-referenced data keys: i18n namespace pages.press -> pages.blog (removed stale orphan pages.blog stub), section key home.press -> home.blog, DOM id press -> blog - packages/ui: NavOverlayPressItem -> NavOverlayBlogItem, press/pressSeeAllHref -> blog/blogSeeAllHref (rebuilt dist); navigation.json + site schema press -> blog Intentionally kept (not LPE branding): circles "press" date-format surface (formatPressDate/event date style), image asset filenames (press-*.webp, press-hero.jpg), and link-policy legacy-fixture guards. Verified: web tsc clean, 61 web tests pass, content types + 29 validations pass, @acid-info/logos-ui rebuilds clean.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/**
|
|
* Shared types and helpers for App Router page parameters.
|
|
*
|
|
* Next.js 15 made `params` a Promise on every page; the resulting type
|
|
* (`{ params: Promise<{ locale: string }> }`) appears in 40+ places. Centralising
|
|
* it removes the repetition and gives us one place to add new params shapes.
|
|
*
|
|
* Likewise the `if (!isActiveLocale(locale)) throw new Error(...)` guard repeats
|
|
* 22 times; `resolveLocale` collapses it to a single line.
|
|
*/
|
|
import { isActiveLocale } from '@repo/content/locales'
|
|
import type { Language } from '@repo/content/schemas'
|
|
|
|
export type LocaleParams = { params: Promise<{ locale: string }> }
|
|
|
|
export type LocaleSlugParams = {
|
|
params: Promise<{ locale: string; slug: string }>
|
|
}
|
|
|
|
/**
|
|
* Resolve and assert the active locale from a route's `params` Promise.
|
|
*
|
|
* Replaces:
|
|
* const { locale } = await params
|
|
* if (!isActiveLocale(locale)) {
|
|
* throw new Error(`BlogPage received non-active locale "${locale}"`)
|
|
* }
|
|
*
|
|
* @param params The `params` Promise from a Next.js App Router page.
|
|
* @param pageName Identifier surfaced in the error message — keep it the same
|
|
* string the page used before (e.g. `"BlogPage"`) so existing
|
|
* log alerts continue to match.
|
|
*/
|
|
export async function resolveLocale(
|
|
params: Promise<{ locale: string }>,
|
|
pageName: string
|
|
): Promise<Language> {
|
|
const { locale } = await params
|
|
if (!isActiveLocale(locale)) {
|
|
throw new Error(`${pageName} received non-active locale "${locale}"`)
|
|
}
|
|
return locale
|
|
}
|