#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Author {
  pub seed: u8,
  pub name: String,
  pub keywords: Vec<String>,
  pub image_url: String,
  pub about: String
}
impl BlogEntry for Author {
  fn from_entry(entry: &mut Entry) -> Self {
    return match entry.seed {
      0 => Self {
        seed: entry.seed,
        name: "iouring".to_string(),
        image_url: "profile.avif".to_string(),
        about: "sup".to_string(),
        keywords: vec![
          "meow".to_string(),
          "mrrp".to_string(),
          "mew".to_string()
        ]
      },
      _ => Self {
        seed: u8::MAX,
        name: "not found".to_string(),
        image_url: "".to_string(),
        about: "".to_string(),
        keywords: vec![]
      }
    }
  }
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PostMeta {
  pub seed: u8,
  pub title: String,
  pub author: Author,
  pub keywords: Vec<String>,
  pub image_url: String,
}
impl BlogEntry for PostMeta {
  fn from_entry(entry: &mut Entry) -> Self {
    return match entry.seed {
      0 => Self {
        seed: entry.seed,
        title: "awawa title".to_string(),
        author: Author::from_entry(entry),
        keywords: vec!["meow".to_string(), "mrrp".to_string(), "mew".to_string()],
        image_url: "testimage.jpg".to_string()
      },
      _ => Self {
        seed: entry.seed,
        title: "not found".to_string(),
        author: Author::from_entry(entry),
        keywords: vec![],
        image_url: "".to_string()
      }
    }
  }
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Post {
  pub meta: PostMeta,
  pub content: Vec<PostPart>,
}
impl BlogEntry for Post {
  fn from_entry(entry: &mut Entry) -> Self {
    return Self {
      meta: PostMeta::from_entry(entry),
      content: vec![PostPart::from_entry(entry)]
    }
  }
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PostPart {
  Section(Section),
  Quote(Quote),
}
impl BlogEntry for PostPart {
  fn from_entry(entry: &mut Entry) -> Self {
    // TODO: ... | add proper logic

    return Self::Section(Section::from_entry(entry))
    // return Self::Quote(Quote::from_entry(entry))
  }
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Section {
  pub title: String,
  pub paragraphs: Vec<String>,
  pub image_url: String,
}
impl BlogEntry for Section {
  fn from_entry(entry: &mut Entry) -> Self {
    return match entry.seed {
      0 => Self {
        title: "awawa title".to_string(),
        image_url: "".to_string(),
        paragraphs: vec![
          "meow 1".to_string(),
          "mrrp 2".to_string(),
          "mew 3".to_string()
        ]
      },
      _ => Self {
        title: "not found".to_string(),
        image_url: "".to_string(),
        paragraphs: vec![]
      },
    }
  }
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Quote {
  pub author: Author,
  pub content: String,
}
impl BlogEntry for Quote {
  fn from_entry(entry: &mut Entry) -> Self {
    return Self { author: Author::from_seed(entry.seed), content: "awawa content".to_string() }
  }
}

pub struct Entry {
  pub seed: u8
}

impl Entry {
  pub fn from_seed(seed: u8) -> Self {
    Self { seed }
  }
}

pub trait BlogEntry: Sized {
  fn from_entry(entry: &mut Entry) -> Self;
  fn from_seed(seed: u8) -> Self {
    Self::from_entry(&mut Entry::from_seed(seed))
  }
}
