Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

941 B
Raw Blame
import type { PlacePhotoCandidate } from '@trek/shared';

/** The name to put under a picture. Google gives no author, so it gets its own name. */
export function creditOf(photo: PlacePhotoCandidate): string {
  return photo.attribution || sourceLabelFor(photo.source);
}

/**
 * The provider a picture came from, for the pictures that hand us no author.
 * Proper names, so they are not translated.
 */
export function sourceLabelFor(source: PlacePhotoCandidate['source']): string {
  if (source === 'google') return 'Google';
  if (source === 'wikipedia') return 'Wikipedia';
  if (source === 'community') return 'TREK Community';
  return 'Wikimedia Commons';
}

/** Author and licence joined for a single-line caption, with a comma as the rest of the app writes it. */
export function photoCaption(photo: PlacePhotoCandidate): string {
  const credit = creditOf(photo);
  return photo.license ? `${credit}, ${photo.license}` : credit;
}