diff --git a/docs/render/recipe.css b/docs/render/recipe.css index 8d316f7..d5d23a6 100644 --- a/docs/render/recipe.css +++ b/docs/render/recipe.css @@ -137,6 +137,7 @@ img.publisher { } header { + flex: 1 1 auto; /* gap: 2em; */ /* margin-bottom: 1rem; */ /* padding-left: 18em; */ diff --git a/docs/render/recipe.html b/docs/render/recipe.html index f86ad46..d100b28 100644 --- a/docs/render/recipe.html +++ b/docs/render/recipe.html @@ -8,18 +8,13 @@ script.onload = resolve; script.src = src document.head.appendChild(script); - console.log("script", script) }) return callback ? promise.then(callback) : promise; } window.addEventListener("message", function(e) { let data = e.data; - // var base = el('base', {href: data.script}); - // console.log("MESSAGE", data, base, data.script); - // document.head.appendChild(base); window.script = data.script - console.log("data.script", data) window.params = data; window.params.origin = e.origin; console.log("πŸ–Šβ€‰Rendering with", {script:data.script, params:data}) @@ -27,8 +22,7 @@ render() loadScript("../js/qrious.min.js", null, "").then(() => { - console.log("qrious loaded", window.params, window.params.originalURL); -var qr = new QRious({ + var qr = new QRious({ element: document.getElementById("qr"), background: 'transparent', foreground: 'currentColor', diff --git a/docs/render/recipe.js b/docs/render/recipe.js index 8395685..847b9a2 100644 --- a/docs/render/recipe.js +++ b/docs/render/recipe.js @@ -27,10 +27,14 @@ var isWatch = (window.outerWidth < 220); if (isWatch) document.documentElement.classList.add("watch") let ignoredTerms = [ - "but", "broken", "pieces", "tbsp", "tsp", "peeled", "then", "can", "oz", "fresh", "out", "not", "sprig", "sprigs", "room", "temperature", "still", "see", "notes", "with", "beat", "together", "crust", "very", "cold", "hot", "top", "warm", "one", "note", "teaspoon", "teaspoons", "tablespoon", "tablespoons", "cup", "cups", "taste", "more", "melted", "into", "wide", "pound", "pounds", "gram", "grams", "you", "ounce", "ounces", "thinly", "sliced", + "freshly", "use", "dry", "but", "broken", "pieces", "tbsp", "tsp", "peeled", "then", "can", "oz", "fresh", "out", "not", "sprig", "sprigs", "room", "temperature", "still", "see", "notes", "with", "beat", "together", "crust", "very", "cold", "hot", "top", "warm", "one", "note", "teaspoon", "teaspoons", "tablespoon", "tablespoons", "cup", "cups", "taste", "more", "melted", "into", "wide", "pound", "pounds", "gram", "grams", "you", "ounce", "ounces", "thinly", "sliced", "pan", "cube", "cubes", "finely", "ground", "garnish", "about", "cut", "and", "smashed", "each", "the", "medium", "large", "small", "for", "chopped", "minced", "grated", "box", "softened", "directed", "shredded", "cooked", "from", "frozen", "thawed" ] let emojiMap = { + "duck": "πŸ—", + "beef": "πŸ₯©", + "turkey": "πŸ—", + "chicken": "πŸ—", "grape": "πŸ‡", "watermelon": "πŸ‰", "melon": "🍈", @@ -76,9 +80,6 @@ let emojiMap = { "waffle": "πŸ§‡", "cheese": "πŸ§€", "meat": "πŸ–", - "beef": "πŸ₯©", - "turkey": "πŸ—", - "chicken": "πŸ—", "steak": "πŸ₯©", "bacon": "πŸ₯“", "hamburger": "πŸ”", @@ -286,7 +287,7 @@ function clean(html) { function formatTime(time) { const timeRE = /(?-)?P(?:(?[.,\d]+)Y)?(?:(?[.,\d]+)M)?(?:(?[.,\d]+)W)?(?:(?[.,\d]+)D)?T(?:(?[.,\d]+)H)?(?:(?[.,\d]+)M)?(?:(?[.,\d]+)S)?/ - let duration = time.match(timeRE).groups; + let duration = time.match(timeRE)?.groups; if (duration) { time = []; @@ -425,10 +426,10 @@ function render() { try { let data = JSON.parse(window.params.body); var json = data; //JSON.parse(data); - if (json["@type"] != "Recipe") { + if (!json["@type"]?.includes("Recipe")) { json = (json["@graph"] ?? json).find((item) => item["@type"] == "Recipe") } - console.log("Recipe", json); + console.log("πŸ— Rendering Recipe:", json); } catch (e) { document.body.appendChild(m("div", "Error parsing recipe", m("p", e.message), m("p", e.stack), m("pre", window.params.body) )); @@ -461,7 +462,7 @@ function render() { ); if (typeof instructions === "string") instructions = [instructions] instructions = flattenInstructions(instructions) - console.log("instructions", instructions) + let intructionTerms = new Set( Array.from(instructions.flat().join("\n").matchAll(/[A-Za-z\-]+/g)).map(m => m[0].length > 2 ? m[0].toLowerCase(): "") ); @@ -614,8 +615,6 @@ function render() { }; bgImg.src = image; - console.log("image", bgImg.src) - let originalURL = json.mainEntityOfPage?.["@id"] ?? ((json.mainEntityOfPage == true) ? false : json.mainEntityOfPage) ?? json.url; let hostname = originalURL ? new URL(originalURL).hostname.replace("www.","") : ""