import type { ChainModifiers, Entry, EntryFieldTypes, EntrySkeletonType, LocaleCode } from 'contentful'
import {Author, AuthorSkeleton} from "./author";
import {ContentImage} from "../lib/contentful/contentImage";
import {BlogPostCategorySkeleton} from "./blogPostCategory";
import {WidgetMedia, WidgetMediaSkeleton} from "./blogWidgets/widgetMedia";
import {WidgetParagraph, WidgetParagraphSkeleton} from "./blogWidgets/widgetParagraph";

export interface BlogPostFields {
    title?: EntryFieldTypes.Symbol
    slug: EntryFieldTypes.Symbol
    excerpt: EntryFieldTypes.Symbol
    metaDescription: EntryFieldTypes.Symbol
    listImage?: EntryFieldTypes.AssetLink
    author?: AuthorSkeleton
    category: BlogPostCategorySkeleton
    createdAt?: EntryFieldTypes.Date
    body?: Array<WidgetMediaSkeleton | WidgetParagraphSkeleton>
}

export interface BlogPostFields extends BlogPostFields{
    body: Array<WidgetMediaSkeleton | WidgetParagraphSkeleton>
}

export interface BlogPost {
    title: string
    slug: string
    excerpt: string
    listImage: ContentImage | null
    author: Author | null
    category: string
    categorySlug: string
    createdAt: string
    metaDescription: string
    body: Array<WidgetMedia | WidgetParagraph>
}

export type BlogPostSkeleton = EntrySkeletonType<BlogPostFields, 'blogPost'>
export type BlogPostEntry<Modifiers extends ChainModifiers, Locales extends LocaleCode> = Entry<
    BlogPostSkeleton,
    Modifiers,
    Locales
>