feat: display nutrition data from metadata#359
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review: feat: display nutrition data from metadataGood implementation overall — the scope is well-controlled (UI-only, no parser/CLI changes), both storage formats are supported, and i18n is handled across all 7 locales. A few things worth addressing: Issue 1:
|
crspybits
left a comment
There was a problem hiding this comment.
Two initial thoughts:
- I believe this is an end-user feature. Do some end-user docs need to be added?
- There are a few places where there is redundancy/duplication in the code. I've called out one specific example. Happy to help with this and/or give other places where I see this. Claude can help with this too.
| serving_size: get("serving size").or_else(|| get("serving_size")), | ||
| }; | ||
|
|
||
| let has_data = data.calories.is_some() |
There was a problem hiding this comment.
This block of code (computing has_data) is duplicated below. If it was me writing this, I'd instead add something like the following, perhaps in templates.rs
impl NutritionData {
pub fn has_data(&self) -> bool {
self.calories.is_some()
|| self.protein.is_some()
|| self.fat.is_some()
|| self.saturated_fat.is_some()
|| self.carbohydrates.is_some()
|| self.fiber.is_some()
|| self.sugar.is_some()
|| self.sodium.is_some()
|| self.serving_size.is_some()
}
}
and call that twice.
Goal
Display nutrition information stored in
.cookrecipe metadata in the web UI, when available. The info are in a collapsible section between the metadata pill and the recipe steps.Two storage formats exist: flat top-level keys (hand-authored) and a nested
nutrition:mapping (from imported recipes).Display only if at least one information is available.
Display the metadata as-is, no checks, no scalings, no fetching data.
Scope
cooklang-rs— nutrition is not aStdKey; we read it from the raw metadata maprecipecommand output — this is UI-onlybuilders.rsupdated for consistencyOut of scope
Specs and implementation plans have been added in docs/
Disclaimer: The implementation has been done using Claude Code. I made the designs decisions and have reviewed the code.