Recipe

Store recipes with ingredients, steps, prep and cook times. Total time is calculated automatically.

A recipe template for your personal cookbook. Each Recipe note holds servings, prep time, cook time, difficulty, ingredients, and steps. The total time is calculated automatically when you save.

Recipe template screenshot

Downloads

How to use

  1. Import recipe.rhai in Settings → Scripts → Import Script
  2. Create a new note and choose Recipe as the type
  3. Give it a title (e.g. the dish name)
  4. Fill in servings, prep time (minutes), cook time (minutes), and difficulty
  5. Add ingredients and steps in the text areas
  6. Save — the total time is computed and displayed automatically

How it works

Recipe schema — on_save hook

On save, the total_time field is computed by adding prep_time and cook_time. The result is formatted in a human-readable way:

TotalDisplay
0 or less(blank)
Under 60 mine.g. “45 min”
60+ mine.g. “1h 30min”

The total_time field is read-only — it cannot be edited directly.

Hover preview

Hovering over a Recipe shows the difficulty, total time, and number of servings.

Schema

schema("Recipe", #{
    version: 1,
    title_can_edit: true,
    fields: [
        #{ name: "servings",    type: "number",   required: false                  },
        #{ name: "prep_time",   type: "number",   required: false                  },
        #{ name: "cook_time",   type: "number",   required: false                  },
        #{ name: "difficulty",  type: "select",   required: false,
           options: ["Easy", "Medium", "Hard"]                                     },
        #{ name: "ingredients", type: "textarea", required: false                  },
        #{ name: "steps",       type: "textarea", required: false                  },
        #{ name: "total_time",  type: "text",     required: false, can_edit: false  },
    ],
    on_save: |note| {
        let prep  = note.fields["prep_time"];
        let cook  = note.fields["cook_time"];
        let total = (prep + cook).to_int();

        set_field(note.id, "total_time",
            if total <= 0 {
                ""
            } else if total < 60 {
                total.to_string() + " min"
            } else {
                let h = total / 60;
                let m = total % 60;
                if m == 0 { h.to_string() + "h" }
                else      { h.to_string() + "h " + m.to_string() + "min" }
            });

        commit();
    }
});