Skip to content
mattbatPublic

About

A personal cookbook powered by gh-pages, markdown, jekyll and ✨

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

804 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📖 Cookbook

The Batchelder family cookbook: mattbat.com/cookbook.

Every recipe is a markdown file in _recipes/. Add or change one on master and the site rebuilds, tests itself, and publishes on its own.

Adding a recipe

  1. Copy _recipes/_template/template.md to _recipes/my-new-recipe.md (lowercase, with hyphens: the file name becomes the web address).
  2. Put the photo in img/ and point to it: ![Image of My New Recipe](../img/my-new-recipe.jpeg).
  3. Fill in the details at the top (author, servings, tags, ...) and the recipe itself: one # Title, then ## Ingredients as a - list and ## Steps as a 1. list (see below).
  4. Commit to master, either from your computer or with Add file on github.com.

How a recipe file is written

Recipes are plain markdown so they stay usable whatever the website becomes. Keep them consistent:

  • Top block (front matter)
    • date: the day it was added, YYYY-MM-DD
    • prep_time, cooking_time: whole minutes (90, not 1.5 hr)
    • servings: a number; add servingsUnit: Cups (or Pints, Cookies…) when it isn't people
    • author: who makes it in the family; source: where it came from, as a name; sourceUrl: a link to the original
    • tags: lowercase, from the list in tests/content/recipes.test.mjs (add new ones there)
  • Sections: ## Ingredients, ## Steps, ## Notes, and when needed ## Tools (equipment) and ## Videos (- Cook: <https://…>). Sub-groups go under ### Crust, ### Filling…
  • Ingredients: - amount unit item, prep (note), e.g. - 1½ cups red onion, finely chopped
    • Units: tsp, Tbsp, cup/cups, oz, lb, with a space after the number
    • Fractions as ½ ¼ ¾ ⅓ ⅔ ⅛ (1½, not 1 1/2)
    • Ranges as 2 to 3, so the serving-size buttons scale both numbers
    • Equipment goes in ## Tools, not the ingredient list (it would be scaled)
  • Steps: a 1. list with one line per step and no blank lines between steps
  • Notes: a - list
  • Temperatures as 350°F (the degree sign °, not º)

npm run test:unit checks most of this and says exactly what to fix.

With Claude, from your phone or computer

The repo includes a Claude Code skill (.claude/skills/add-recipe/) that does all of the above. Give it a photo of a recipe card or cookbook page, a website link, or pasted text, for example:

add this recipe to the cookbook: https://www.kingarthurbaking.com/recipes/classic-sandwich-bread-recipe

add grandma's card to the cookbook, by Tracy Batchelder [photo]

It reads the recipe, writes _recipes/<name>.md in the house style (rewording the steps rather than copying a website), saves the photo, runs the recipe checks, and opens a pull request. Merging the pull request publishes it. It tells you what it guessed (times, tags) so you can correct it in the same chat.

  • On your phone: in the Claude app, start a Code session on the mattbat/cookbook repository (Claude Code on the web) and ask as above. To import from websites there, the environment needs internet access to those sites; if a page won't load, paste the recipe text or a screenshot.
  • On your computer: run claude in this folder, or use the Claude desktop app, and ask the same way.
  • Photos: a website's photo isn't used unless you ask ("use the website's photo"), since the cookbook is public. Without a photo of the dish, it adds a plain placeholder; replace img/<name>.jpeg with your own photo any time.

Or let the tools write the file for you:

npm run new "Grandma's Pot Roast"
npm run import https://example.com/some-recipe

(import needs a Spoonacular API key: copy CLI/CREDENTIALS.example.json to CLI/CREDENTIALS.json and add your key.)

Working on the site locally

You need Node.js 22 or newer. Once, after cloning:

npm install
npx playwright install chromium webkit

Then:

Command What it does
npm start Builds the site and serves it at http://localhost:8080/cookbook/, rebuilding as you save
npm test Everything below, in order (what GitHub runs before publishing)
npm run test:unit Checks every recipe file, and the serving-size math (a couple of seconds)
npm run build Builds the site into _site/
npm run test:build Checks the built site: every old address still works, no broken links or photos
npm run test:e2e Clicks through the site on an iPhone, an Android phone and a desktop browser
npm run test:e2e:ui Same, in a window where you can watch each test and step through it

If npm start is already running, the browser tests use it instead of starting their own server. After a failed browser test, npx playwright show-report shows screenshots and a step-by-step trace.

On Windows PowerShell, type npm.cmd instead of npm if PowerShell says running scripts is disabled.

To try the site on your phone, run npm start, connect the phone to the same Wi-Fi, and open http://<your computer's IP address>:8080/cookbook/ (ipconfig shows the address).

Known issues are tests too

Bugs we know about have tests marked test.fail (browser tests) or todo (unit tests). They pass today because the bug is still there. When a fix lands, that test starts complaining ("expected to fail, but passed"); remove the marker so it guards the fix from then on.

How publishing works

.github/workflows/site.yml runs on every push to master, on pull requests, and on demand from the Actions tab:

  1. Checks every recipe file and the scaling math
  2. Builds the site with Eleventy
  3. Checks the built site (addresses, links, photos)
  4. Runs the browser tests
  5. Publishes to GitHub Pages, but only from master and only if everything above passed

If anything fails, the live site stays as it was, GitHub emails you, and the run's page shows the exact problem (for example gumbo.md: img/gumbo.jpg not found).

Turning on publishing (one-time cutover)

Until this is done, GitHub's old built-in Jekyll build is still what publishes the site.

  1. Settings → Pages → Build and deployment → Source: choose GitHub Actions. The current site stays up until the next publish.
  2. Settings → Secrets and variables → Actions → Variables: add PAGES_DEPLOY = actions.
  3. Merge to master (or run the workflow from the Actions tab).

Tech

Built with Eleventy, searched with MiniSearch, tested with Playwright and Node's built-in test runner, and hosted on GitHub Pages. No CSS or JavaScript framework: the look is in css/site.css, page behaviour in js/:

File Where What
app.js every page tap a step to keep your place; shared helpers
timers.js every page times in the steps ("simmer 30-40 minutes") become timer buttons; running timers follow you between pages
search.js Search tab search and category filters
recipe-scaling.js recipes the servings stepper (and metric amounts in the ingredients)
units.js recipes the US / Metric switch: dry ingredients in cups are weighed (g), liquids in mL, °C and cm; teaspoons and tablespoons stay as written
kitchen.js recipes ingredient check-offs, Copy list, Share, Keep screen on, Cook mode
offline.js offline page lists the recipes saved on this device

Every recipe page also carries schema.org Recipe data (built by recipeJsonLd in lib/recipes.js), so Google and recipe apps can read the ingredients, steps and times. Steps are the numbered lists under a ## Steps heading (### sub-headings inside it are fine); Notes lists aren't steps.

Keep screen on, the share sheet and the clipboard need a secure (https) page, so when you test on your phone at http://<your IP>:8080 the Keep screen on button is hidden and Share copies the link instead. On the live site they all work.

App and offline

  • Add to Home Screen makes the cookbook open full screen with its own icon (manifest.webmanifest.njk; the icon is drawn in lib/icons.js and saved as PNGs during the build). The home page shows a card explaining how, until it's installed or dismissed.
  • Offline: sw.js.njk is a service worker that saves the site on the phone. Pages are always fetched fresh when there's signal (after 4 seconds on a weak signal, the saved copy is used); recipes you've opened before work with no signal at all, and other pages show /offline/, which lists the saved recipes. It needs https, so it doesn't run when testing on a phone over http://.
  • Photos: lib/photos.js makes smaller copies of every photo in img/ (240 to 1600 pixels wide, in img/w/), and pages use srcset so phones download one about the size of their screen. Copies are kept in .cache/photos so only new or changed photos are resized; the first build after cloning takes about 30 seconds longer. Keep adding full-size photos to img/ as before.

If npm start is running, stop it before npm test: both write to _site/. Restart npm start after changing eleventy.config.mjs, lib/ or _data/, which it doesn't reload on its own.

The site's sections (the bottom tabs on phones, the top links on desktop) and the category list are set in _data/site.json. A category only appears once at least one recipe has its tag.

Originally based on jansim/cookbook and the beautiful-jekyll theme by Dean Attali.

About

A personal cookbook powered by gh-pages, markdown, jekyll and ✨

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages