/** Shapes returned by the Ghost Content API (only the fields this site consumes). */

export interface GhostTag {
  id: string;
  name: string;
  slug: string;
  visibility: string;
}

export interface GhostAuthor {
  id: string;
  name: string;
  slug: string;
  profile_image: string | null;
}

export interface GhostPost {
  id: string;
  uuid: string;
  title: string;
  slug: string;
  html: string | null;
  excerpt: string | null;
  custom_excerpt: string | null;
  feature_image: string | null;
  feature_image_alt: string | null;
  published_at: string | null;
  updated_at: string | null;
  reading_time: number | null;
  url: string | null;
  canonical_url: string | null;
  meta_title: string | null;
  meta_description: string | null;
  og_title: string | null;
  og_description: string | null;
  og_image: string | null;
  twitter_title: string | null;
  twitter_description: string | null;
  twitter_image: string | null;
  tags?: GhostTag[];
  primary_author?: GhostAuthor | null;
  authors?: GhostAuthor[];
}

export interface GhostPostsResponse {
  posts: GhostPost[];
}

/**
 * A post normalised for rendering: every field is resolved to a usable value so
 * templates never have to branch on missing Ghost data.
 */
export interface BlogPost {
  slug: string;
  title: string;
  html: string;
  excerpt: string;
  featureImage: string | null;
  featureImageAlt: string;
  author: string;
  publishedAt: Date | null;
  /** Pre-formatted for display, e.g. "Jun 2, 2026". Empty when unpublished. */
  publishedLabel: string;
  /** ISO-8601, for <time datetime> and Article schema. */
  publishedIso: string;
  readingTime: number;
  /** Public tags only; the routing tag is stripped out. */
  tags: GhostTag[];
  /** Uppercased primary tag used in the card caption, e.g. "OPERATIONS". */
  primaryTagLabel: string;
  seo: PostSeo;
}

export interface PostSeo {
  metaTitle: string;
  metaDescription: string;
  ogTitle: string;
  ogDescription: string;
  ogImage: string | null;
  twitterTitle: string;
  twitterDescription: string;
  twitterImage: string | null;
  canonicalUrl: string;
}

export interface GhostConfig {
  apiUrl: string;
  contentApiKey: string;
  /** Public origin of this site, used to build canonical URLs. */
  siteUrl: string;
}
