fix: soo many lint errors
This commit is contained in:
@@ -68,6 +68,7 @@ export const ReviewContentSchema = makeContentSchema("Review", {
|
||||
export const RecipeContentSchema = makeContentSchema("Recipe", {
|
||||
description: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
reviewRating: ReviewRatingSchema.optional(),
|
||||
recipeIngredient: z.array(z.string()).optional(),
|
||||
recipeInstructions: z.array(z.string()).optional(),
|
||||
totalTime: z.string().optional(),
|
||||
@@ -124,3 +125,16 @@ export type RecipeResource = z.infer<typeof RecipeSchema> & {
|
||||
export type GenericResource = z.infer<typeof GenericResourceSchema> & {
|
||||
image?: typeof imageTable.$inferSelect;
|
||||
};
|
||||
|
||||
export function getNameOfResource(res: GenericResource): string {
|
||||
if (res.content?._type === "Article" && res.content.headline) {
|
||||
return res.content.headline;
|
||||
}
|
||||
if (res.content?._type === "Review" && res.content.itemReviewed?.name) {
|
||||
return res.content.itemReviewed.name;
|
||||
}
|
||||
if (res.content?._type === "Recipe" && res.content.name) {
|
||||
return res.content.name;
|
||||
}
|
||||
return "Unnamed Resource";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user