package templates import ( domain "github.com/haydenhargreaves/Potion/internal/domain/recipe" domainUser "github.com/haydenhargreaves/Potion/internal/domain/user" "github.com/haydenhargreaves/Potion/internal/templates/components" "time" ) templ servingIcon() { } templ timeIcon() { } templ starIcon(filled bool) { if filled { } else { } } templ RecipePage(recipe domain.Recipe, user domainUser.User) { @components.Navbar("")

{ recipe.Title }

Author: { user.Name }

Category: { recipe.Category }

@metadataSection(recipe)

About this recipe

{ recipe.Description }

@ingredientList(recipe.Ingredients) @instructionList(recipe.Instructions) @tagList(recipe.Created, recipe.Modified)
} templ metadataSection(recipe domain.Recipe) {
@timeIcon()

Prep: { recipe.Duration.Prep } min

Cook: { recipe.Duration.Cook } min

for _ = range recipe.Difficulty { @starIcon(true) } for _ = range (5 - recipe.Difficulty) { @starIcon(false) }

{ recipe.Difficulty }

@servingIcon()

Serves { recipe.Serves }

} templ ingredientList(ingredients []domain.RecipeIngredient) {

Ingredients


} templ instructionList(instructions []string) {

Instructions


} templ tagList(created time.Time, modified *time.Time) {

Tags



Created: { created.Format("January 2, 2006") }

if modified != nil {

Last Modified: { modified.Format("January 2, 2006") }

}
} templ ingredientListItem(name, quantity string, odd bool) {
  • { quantity }: { name }
  • } templ instructionListItem(num int, content string) {
  • { num }

    { content }

  • } templ tagListItem(content string) {
  • { content }
  • }