mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
Handle undefineds
This commit is contained in:
parent
e9fa517494
commit
70c48b0c65
2 changed files with 6 additions and 6 deletions
File diff suppressed because one or more lines are too long
|
|
@ -232,6 +232,7 @@ const m = (selector, ...args) => {
|
|||
};
|
||||
|
||||
function clean(html) {
|
||||
if (!html) return;
|
||||
let doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return doc.body.textContent || "";
|
||||
}
|
||||
|
|
@ -394,11 +395,10 @@ function render() {
|
|||
image = image?.url || image;
|
||||
let instructions = json.recipeInstructions;
|
||||
let title = clean(json.name);
|
||||
let description = clean(json.description.replace(/\\n/g, "<br>"))
|
||||
let description = clean(json.description?.replace(/\\n/g, "<br>"))
|
||||
let favicon = faviconForTitle(title) || "🍴";
|
||||
parent.postMessage({title:title, favicon:favicon, image:image, description:description, wakeLock:true, updateURL:true}, "*");
|
||||
description = description.split("\n").join("<p>")
|
||||
|
||||
description = description?.split("\n").join("<p>")
|
||||
// let text = instructions.join(" ");
|
||||
let ingredients = json.recipeIngredient;
|
||||
|
||||
|
|
@ -472,9 +472,8 @@ function render() {
|
|||
return instruction.map(i => flattenInstructions(i));
|
||||
}
|
||||
|
||||
let text = (instruction.text || instruction);
|
||||
let text = (instruction.text || instruction.name || instruction);
|
||||
|
||||
console.log()
|
||||
if (reformat) {
|
||||
text = stepsFromText(text);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue