fix: make recipe crawling work
This commit is contained in:
@@ -18,8 +18,9 @@ export const IngredientGroupSchema = z.object({
|
||||
export type IngredientGroup = z.infer<typeof IngredientGroupSchema>;
|
||||
|
||||
const recipeSchema = z.object({
|
||||
_type: z.literal("Recipe"),
|
||||
name: z.string().describe(
|
||||
"Title of the Recipe, without the name of the website or author",
|
||||
"Name of the Recipe, without the name of the website or author",
|
||||
),
|
||||
description: z.string().describe(
|
||||
"Optional, short description of the recipe",
|
||||
@@ -41,11 +42,7 @@ const recipeSchema = z.object({
|
||||
|
||||
export type Recipe = z.infer<typeof recipeSchema>;
|
||||
|
||||
const noRecipeSchema = z.object({
|
||||
errorMessages: z.array(z.string()).describe(
|
||||
"List of error messages, if no recipe was found",
|
||||
),
|
||||
});
|
||||
const noRecipeSchema = z.literal("none").describe("No Recipe found");
|
||||
|
||||
export const recipeResponseSchema = z.union([recipeSchema, noRecipeSchema]);
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
export const resources = {
|
||||
"home": {
|
||||
emoji: "House with Garden.png",
|
||||
emoji: "home_icon.png",
|
||||
name: "Home",
|
||||
link: "/",
|
||||
},
|
||||
"recipe": {
|
||||
emoji: "Fork and Knife with Plate.png",
|
||||
emoji: "recipes_icon.png",
|
||||
name: "Recipes",
|
||||
link: "/recipes",
|
||||
},
|
||||
"movie": {
|
||||
emoji: "Popcorn.png",
|
||||
emoji: "movies_icon.png",
|
||||
name: "Movies",
|
||||
link: "/movies",
|
||||
},
|
||||
"article": {
|
||||
emoji: "Writing Hand Medium-Light Skin Tone.png",
|
||||
emoji: "articles_icon.png",
|
||||
name: "Articles",
|
||||
link: "/articles",
|
||||
},
|
||||
"series": {
|
||||
emoji: "Television.png",
|
||||
emoji: "tv_series_icon.png",
|
||||
name: "Series",
|
||||
link: "/series",
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ export function safeFileName(input: string): string {
|
||||
.normalize("NFKD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/[\s-]+/g, "_")
|
||||
.replace(/-+/g, "-")
|
||||
.replace(/[^A-Za-z0-9_]+/g, "")
|
||||
.replace(/_+/g, "_")
|
||||
// Trim underscores/dots from ends and prevent leading dots
|
||||
|
||||
@@ -181,7 +181,7 @@ export async function webScrape(
|
||||
|
||||
return {
|
||||
...result,
|
||||
dom,
|
||||
dom: dom.window.document,
|
||||
markdown: turndownService.turndown(result.content),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user