From a028b8ce3a02fd9440237c6ce0c1d571ba5d2da7 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Sun, 12 Apr 2026 09:47:09 +0200 Subject: [PATCH] feat: Enhance recipeToMarkdown to include source URL in output --- .../src/quick-import/quick-import.service.ts | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/backend/src/quick-import/quick-import.service.ts b/backend/src/quick-import/quick-import.service.ts index d3a51385..0f71d8cb 100644 --- a/backend/src/quick-import/quick-import.service.ts +++ b/backend/src/quick-import/quick-import.service.ts @@ -122,7 +122,7 @@ export class QuickImportService { } // Konvertera till Markdown-format - const markdown = this.recipeToMarkdown(recipe); + const markdown = this.recipeToMarkdown(recipe, url); console.log('[QuickImport] Markdown genererad, längd:', markdown.length); // Detektera källa från URL @@ -147,16 +147,19 @@ export class QuickImportService { /** * Konvertera receptobjekt till Markdown-format */ - private recipeToMarkdown(recipe: { - name: string; - description?: string; - ingredients: Array<{ - quantity: number; - unit: string; + private recipeToMarkdown( + recipe: { name: string; - }>; - instructions?: string; - }): string { + description?: string; + ingredients: Array<{ + quantity: number; + unit: string; + name: string; + }>; + instructions?: string; + }, + sourceUrl?: string, + ): string { const lines: string[] = []; // Titel @@ -184,6 +187,14 @@ export class QuickImportService { if (recipe.instructions) { lines.push('## Tillvägagångssätt'); lines.push(recipe.instructions); + lines.push(''); + } + + // Källa + if (sourceUrl) { + lines.push('---'); + lines.push(''); + lines.push(`Källa: [${sourceUrl}](${sourceUrl})`); } return lines.join('\n');