feat: add recipe and OpenFoodFacts search to nutrition food search
Recipes from /rezepte now appear in the food search on /fitness/nutrition, with per-100g nutrition computed server-side from ingredient mappings. Recipe results are boosted above BLS/USDA/OFF in search ranking. OpenFoodFacts products are now searchable by name/brand via MongoDB text index, alongside the existing barcode lookup. Recipe and OFF queries run in parallel with in-memory BLS/USDA scans.
This commit is contained in:
@@ -156,6 +156,7 @@
|
||||
if (source === 'bls') return 'BLS';
|
||||
if (source === 'usda') return 'USDA';
|
||||
if (source === 'off') return 'OFF';
|
||||
if (source === 'recipe') return '🍴';
|
||||
return source?.toUpperCase() ?? '';
|
||||
}
|
||||
|
||||
@@ -402,7 +403,7 @@
|
||||
<div class="fs-result-info">
|
||||
<span class="fs-result-name">{item.name}</span>
|
||||
<span class="fs-result-meta">
|
||||
<span class="fs-source-badge" class:usda={item.source === 'usda'} class:off={item.source === 'off'}>{sourceLabel(item.source)}</span>
|
||||
<span class="fs-source-badge" class:usda={item.source === 'usda'} class:off={item.source === 'off'} class:recipe={item.source === 'recipe'}>{sourceLabel(item.source)}</span>
|
||||
{#if item.brands}<span class="fs-result-brands">{item.brands}</span>{/if}
|
||||
{#if item.category}{item.category}{/if}
|
||||
</span>
|
||||
@@ -426,7 +427,7 @@
|
||||
<div class="fs-selected">
|
||||
<div class="fs-selected-header">
|
||||
<span class="fs-selected-name">
|
||||
<span class="fs-source-badge" class:usda={selected.source === 'usda'} class:off={selected.source === 'off'}>{sourceLabel(selected.source)}</span>
|
||||
<span class="fs-source-badge" class:usda={selected.source === 'usda'} class:off={selected.source === 'off'} class:recipe={selected.source === 'recipe'}>{sourceLabel(selected.source)}</span>
|
||||
{selected.name}
|
||||
</span>
|
||||
{#if selected.brands}
|
||||
@@ -689,6 +690,12 @@
|
||||
background: color-mix(in srgb, var(--nord15) 15%, transparent);
|
||||
color: var(--nord15);
|
||||
}
|
||||
.fs-source-badge.recipe {
|
||||
background: color-mix(in srgb, var(--nord14) 15%, transparent);
|
||||
color: var(--nord14);
|
||||
font-size: 0.7rem;
|
||||
padding: 0.02rem 0.15rem;
|
||||
}
|
||||
.fs-result-cal {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
|
||||
Reference in New Issue
Block a user