import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { ContentBlock } from "./content-block.entity";

@Entity("pages")
export class Page {
  @PrimaryGeneratedColumn("uuid")
  id!: string;

  // Matches the frontend route this page's content belongs to, e.g. "home",
  // "website", "seo/technical-seo" — not a URL, just a stable lookup key.
  @Column({ unique: true })
  slug!: string;

  @Column()
  title!: string;

  @OneToMany(() => ContentBlock, (block) => block.page)
  blocks!: ContentBlock[];

  @CreateDateColumn({ name: "created_at" })
  createdAt!: Date;

  @UpdateDateColumn({ name: "updated_at" })
  updatedAt!: Date;
}
