fix: soo many lint errors
This commit is contained in:
@@ -25,11 +25,14 @@ export function parseJsonLdToRecipeSchema(jsonLdContent: string) {
|
||||
);
|
||||
|
||||
const instructions = Array.isArray(data.recipeInstructions)
|
||||
? data.recipeInstructions.map((instr) => {
|
||||
? data.recipeInstructions.map((instr: unknown) => {
|
||||
if (!instr) return "";
|
||||
if (typeof instr === "string") return instr;
|
||||
if (typeof instr === "object" && instr.text) return instr.text;
|
||||
if (typeof instr === "object" && "text" in instr && instr.text) {
|
||||
return instr.text;
|
||||
}
|
||||
return "";
|
||||
}).filter((instr) => instr.trim() !== "")
|
||||
}).filter((instr: string) => instr.trim() !== "")
|
||||
: [];
|
||||
|
||||
// Parse servings
|
||||
@@ -53,7 +56,7 @@ export function parseJsonLdToRecipeSchema(jsonLdContent: string) {
|
||||
title: data.name || "Unnamed Recipe",
|
||||
image: pickImage(image || data.image || ""),
|
||||
author: Array.isArray(data.author)
|
||||
? data.author.map((a: any) => a.name).join(", ")
|
||||
? data.author.map((a: { name: string }) => a.name).join(", ")
|
||||
: data.author?.name || "",
|
||||
description: data.description || "",
|
||||
ingredients,
|
||||
@@ -81,7 +84,7 @@ function pickImage(images: string | string[]): string {
|
||||
return images;
|
||||
}
|
||||
|
||||
function parseServings(servingsData: any): number {
|
||||
function parseServings(servingsData: unknown): number {
|
||||
if (typeof servingsData === "string") {
|
||||
const match = servingsData.match(/\d+/);
|
||||
return match ? parseInt(match[0], 10) : 1;
|
||||
|
||||
Reference in New Issue
Block a user