-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add meta tags * Compat with Next15 * Move util out of a hook
- Loading branch information
Showing
17 changed files
with
239 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
apps/web/src/app/(private)/datasets/preview/[datasetId]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { NotFoundError } from '@latitude-data/core/lib/errors' | ||
import buildMetatags from '$/app/_lib/buildMetatags' | ||
import { getEvaluationByUuidCached } from '$/app/(private)/_data-access' | ||
import type { ResolvingMetadata } from 'next' | ||
import { notFound } from 'next/navigation' | ||
|
||
export async function generateMetadata( | ||
{ | ||
params, | ||
}: { | ||
params: Promise<{ evaluationUuid: string }> | ||
}, | ||
parent: ResolvingMetadata, | ||
) { | ||
const { evaluationUuid } = await params | ||
|
||
try { | ||
const evaluation = await getEvaluationByUuidCached(evaluationUuid) | ||
|
||
return buildMetatags({ | ||
title: evaluation.name, | ||
parent: await parent, | ||
}) | ||
} catch (error) { | ||
if (error instanceof NotFoundError) return notFound() | ||
throw error | ||
} | ||
} | ||
|
||
export default async function EvaluationLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: ReactNode | ||
}>) { | ||
return <>{children}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import buildMetatags from '$/app/_lib/buildMetatags' | ||
|
||
export const metadata = buildMetatags({ | ||
title: 'Evaluations', | ||
}) | ||
|
||
export default async function EvaluationsLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: ReactNode | ||
}>) { | ||
return <>{children}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/web/src/app/(private)/projects/[projectId]/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { NotFoundError } from '@latitude-data/core/lib/errors' | ||
import buildMetatags from '$/app/_lib/buildMetatags' | ||
import { findProjectCached } from '$/app/(private)/_data-access' | ||
import { getCurrentUser } from '$/services/auth/getCurrentUser' | ||
import type { ResolvingMetadata } from 'next' | ||
import { notFound } from 'next/navigation' | ||
|
||
export async function generateMetadata( | ||
{ | ||
params, | ||
}: { | ||
params: Promise<{ projectId: string }> | ||
}, | ||
parent: ResolvingMetadata, | ||
) { | ||
const { projectId } = await params | ||
|
||
try { | ||
const session = await getCurrentUser() | ||
const project = await findProjectCached({ | ||
projectId: Number(projectId), | ||
workspaceId: session.workspace.id, | ||
}) | ||
|
||
return buildMetatags({ | ||
title: project.name, | ||
parent: await parent, | ||
}) | ||
} catch (error) { | ||
if (error instanceof NotFoundError) return notFound() | ||
throw error | ||
} | ||
} | ||
|
||
export default async function ProjectLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: ReactNode | ||
}>) { | ||
return <>{children}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import buildMetatags from '$/app/_lib/buildMetatags' | ||
|
||
export const metadata = buildMetatags({ | ||
title: 'Projects', | ||
}) | ||
|
||
export default async function ProjectsLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: ReactNode | ||
}>) { | ||
return <>{children}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { env } from '@latitude-data/env' | ||
import type { Metadata, ResolvedMetadata } from 'next' | ||
|
||
const DEFAULT_TITLE = 'The Open-Source LLM Development Platform' | ||
const DEFAULT_DESCRIPTION = | ||
'Latitude is an end-to-end platform for prompt engineering where domain experts can collaborate with engineers to ship and maintain production-grade LLM features.' | ||
|
||
// This function is necessary to define default metadata correctly, because | ||
// Nextjs metadata merging would overwrite the nested objects totally. | ||
export default function buildMetatags({ | ||
title, | ||
description, | ||
parent, | ||
}: { | ||
title?: string | ||
description?: string | ||
parent?: ResolvedMetadata | ||
}): Metadata { | ||
let parentTitle = parent?.title?.absolute || '' | ||
let metaTitle = | ||
title && parentTitle | ||
? `${title} - ${parentTitle}` | ||
: title || parentTitle || DEFAULT_TITLE | ||
if (!metaTitle.endsWith(' - Latitude')) metaTitle += ' - Latitude' | ||
|
||
const metaDescription = description || DEFAULT_DESCRIPTION | ||
|
||
return { | ||
metadataBase: new URL(env.LATITUDE_URL), | ||
title: metaTitle, | ||
description: metaDescription, | ||
openGraph: { | ||
// Note, og:url is not set because there is no way to get | ||
// the current url in server components, other than hacks | ||
// like getting it from the HTTP headers... | ||
type: 'website', | ||
siteName: 'Latitude', | ||
title: metaTitle, | ||
description: metaDescription, | ||
}, | ||
twitter: { | ||
card: 'summary', | ||
title: metaTitle, | ||
description: metaDescription, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters