Add a description meta to /recipe pages
- Id
- a8e8aadef3b5389c0aec85f63efaa514e4dd3afd
- Author
- Caio
- Commit time
- 2019-06-10T12:02:23+02:00
Modified src/main/java/co/caio/casserole/component/ModelView.java
.build());
}
+ private String getRecipeDescription(RecipeMetadata recipe) {
+ var sb = new StringBuilder();
+
+ recipe
+ .getCalories()
+ .ifPresent(
+ kcal -> {
+ sb.append("Calories: ");
+ sb.append(kcal);
+ });
+
+ recipe
+ .getTotalTime()
+ .ifPresent(
+ totalTime -> {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append(totalTime);
+ sb.append(" minutes");
+ });
+
+ if (sb.length() > 0) {
+ sb.append(". ");
+ }
+ sb.append(recipe.getNumIngredients());
+ sb.append(" ingredients: ");
+ sb.append(String.join(", ", recipe.getIngredients()));
+
+ return sb.toString();
+ }
+
RockerModel renderSingleRecipe(RecipeMetadata recipe, MetadataService db) {
return Recipe.template(
- new SiteInfo.Builder().title(recipe.getName()).searchIsAutoFocus(false).build(),
+ new SiteInfo.Builder()
+ .title(recipe.getName())
+ .description(getRecipeDescription(recipe))
+ .searchIsAutoFocus(false)
+ .build(),
buildAdapter(recipe, db));
}