From 57f8e855a15ec9ccb0a6bfdf42f702c111e782f0 Mon Sep 17 00:00:00 2001 From: Nicholas Jitkoff Date: Thu, 28 Apr 2022 21:10:15 -0600 Subject: [PATCH] Add title updating --- docs/index.js | 3 +++ docs/render/recipe.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/index.js b/docs/index.js index 8566340..c4d21ff 100644 --- a/docs/index.js +++ b/docs/index.js @@ -37,6 +37,9 @@ // if (e.origin == 'null' || e.origin = ) { if (e.data.title) document.title = e.data.title; if (e.data.favicon) setFavicon(e.data.favicon); + if (e.data.updateURL) { + window.location.pathname = "/" + e.data.title.replace(" ", "_") + "/-/" + e.data.image + } if (e.data.setStorage) document.localStorage.setItem(contentHash, e.data.set); if (e.data.getStorage) document.getElementById("iframe").postMessage(document.localStorage.getItem(contentHash), e.origin) // } diff --git a/docs/render/recipe.js b/docs/render/recipe.js index 1ceb885..b253740 100644 --- a/docs/render/recipe.js +++ b/docs/render/recipe.js @@ -186,7 +186,7 @@ function render() { image = image?.url || image; instructions = json.recipeInstructions; let title = clean(json.name); - parent.postMessage({title:title, favicon:"🍳"}, "*"); + parent.postMessage({title:title, favicon:"🍳", image:image, updateURL:true}, "*"); // let text = instructions.join(" ");