feat(import): enhance image URL extraction and logging during recipe import

This commit is contained in:
Nils-Johan Gynther
2026-04-22 22:08:05 +02:00
parent 28606d7abd
commit 71bc162015
8 changed files with 163 additions and 21 deletions
+22
View File
@@ -83,12 +83,23 @@ function ReceptImport() {
const res = await fetch('/api/quick-import-proxy', { method: 'POST', body: formData });
if (!res.ok) throw new Error(await parseErrorResponse(res));
const data = await res.json();
// eslint-disable-next-line no-console
console.log('[ImportTabsClient:file] quick-import response', {
imageUrl: data.imageUrl ?? null,
imageWarning: data.imageWarning ?? null,
markdownLength: (data.markdown ?? '').length,
});
sessionStorage.setItem('prefilled_markdown', data.markdown ?? '');
if (data.imageUrl) {
sessionStorage.setItem('prefilled_image_url', data.imageUrl);
} else {
sessionStorage.removeItem('prefilled_image_url');
}
// eslint-disable-next-line no-console
console.log('[ImportTabsClient:file] sessionStorage snapshot', {
prefilled_markdown: sessionStorage.getItem('prefilled_markdown')?.length ?? 0,
prefilled_image_url: sessionStorage.getItem('prefilled_image_url'),
});
router.push('/recipes/write');
} catch (err) {
setError(err instanceof Error ? err.message : 'Importen misslyckades.');
@@ -110,12 +121,23 @@ function ReceptImport() {
});
if (!res.ok) throw new Error(await parseErrorResponse(res));
const data = await res.json();
// eslint-disable-next-line no-console
console.log('[ImportTabsClient:url] quick-import response', {
imageUrl: data.imageUrl ?? null,
imageWarning: data.imageWarning ?? null,
markdownLength: (data.markdown ?? '').length,
});
sessionStorage.setItem('prefilled_markdown', data.markdown ?? '');
if (data.imageUrl) {
sessionStorage.setItem('prefilled_image_url', data.imageUrl);
} else {
sessionStorage.removeItem('prefilled_image_url');
}
// eslint-disable-next-line no-console
console.log('[ImportTabsClient:url] sessionStorage snapshot', {
prefilled_markdown: sessionStorage.getItem('prefilled_markdown')?.length ?? 0,
prefilled_image_url: sessionStorage.getItem('prefilled_image_url'),
});
router.push('/recipes/write');
} catch (err) {
setError(err instanceof Error ? err.message : 'Importen misslyckades.');