TenantAtlas/apps/website/src/lib/seo.ts
Ahmed Darrazi 27d520b4aa
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 1m10s
feat: implement website core pages IA
2026-04-19 12:16:45 +02:00

36 lines
1.1 KiB
TypeScript

import { getCanonicalPath, getPageDefinition, publishedSitemapRoutes, siteMetadata } from '@/lib/site';
import type { PageFamily, PageRole, PageSeo, ShellTone } from '@/types/site';
export interface ResolvedSeo extends PageSeo {
canonicalUrl: string;
family: PageFamily;
ogDescription: string;
ogTitle: string;
pageRole: PageRole;
robots: string;
shellTone: ShellTone;
}
export function buildCanonicalUrl(path: string): string {
return new URL(getCanonicalPath(path), siteMetadata.siteUrl).toString();
}
export function resolveSeo(seo: PageSeo): ResolvedSeo {
const definition = getPageDefinition(seo.path);
return {
...seo,
canonicalUrl: buildCanonicalUrl(seo.path),
family: definition.family,
ogDescription: seo.ogDescription ?? seo.description,
ogTitle: seo.ogTitle ?? seo.title,
pageRole: definition.pageRole,
robots: 'index,follow',
shellTone: definition.shellTone,
};
}
export async function sitemapEntries(): Promise<string[]> {
return [...publishedSitemapRoutes].map((path) => buildCanonicalUrl(path));
}