Skip to content

Commit

Permalink
Reorder types
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Oct 2, 2024
1 parent f48d6fc commit 410a061
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/model/content/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ export enum FieldType {
}

export type Post = GenericPost< any, PostFields< any, FieldType > >;
export type PostField = GenericField< FieldType >;

export type DateField = GenericField< FieldType.Date > & {
value: Date;
};
export type TextField = GenericField< FieldType.Text >;
export type HtmlField = GenericField< FieldType.Html >;

export interface GenericPost<
Type extends PostType,
Expand All @@ -25,20 +32,12 @@ export interface GenericPost<
fields: Fields;
}

export type PostField = GenericField< FieldType >;

interface GenericField< T extends FieldType > {
export interface GenericField< T extends FieldType > {
type: T;
original: string;
parsed: string;
}

export type DateField = GenericField< FieldType.Date > & {
value: Date;
};
export type TextField = GenericField< FieldType.Text >;
export type HtmlField = GenericField< FieldType.Html >;

type PostFields< FieldName extends string, T extends FieldType > = {
[ Property in keyof FieldName ]: GenericField< T >;
};
Expand Down

0 comments on commit 410a061

Please sign in to comment.