fix: make recipe crawling work

This commit is contained in:
Max Richter
2025-11-12 15:41:30 +01:00
parent 92126882b6
commit 7ad08daf80
19 changed files with 44 additions and 55 deletions

View File

@@ -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]);

View File

@@ -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",
},

View File

@@ -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

View File

@@ -181,7 +181,7 @@ export async function webScrape(
return {
...result,
dom,
dom: dom.window.document,
markdown: turndownService.turndown(result.content),
};
}