({ params }: PublicFilePageProps)
| 34 | * filename never leaks before the visitor authenticates. Always `noindex`. |
| 35 | */ |
| 36 | export async function generateMetadata({ params }: PublicFilePageProps): Promise<Metadata> { |
| 37 | const { token } = await params |
| 38 | const resolved = await resolveShare(token) |
| 39 | if (!resolved) { |
| 40 | return { robots: NOINDEX } |
| 41 | } |
| 42 | |
| 43 | let title: string |
| 44 | let description: string |
| 45 | if (resolved.share.authType !== 'public') { |
| 46 | title = 'Shared file' |
| 47 | description = 'Authentication is required to view this file.' |
| 48 | } else { |
| 49 | title = resolved.file.originalName |
| 50 | description = |
| 51 | buildProvenance(resolved.workspaceName, resolved.ownerName) || `Shared file · ${title}` |
| 52 | } |
| 53 | |
| 54 | const brand = getBrandConfig() |
| 55 | return { |
| 56 | title, |
| 57 | description, |
| 58 | robots: NOINDEX, |
| 59 | openGraph: { type: 'website', title, description, siteName: brand.name }, |
| 60 | twitter: { card: 'summary_large_image', title, description }, |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** The auth-relevant slice of a resolved share row. */ |
| 65 | interface GateShare { |
nothing calls this directly
no test coverage detected