From f63623a14775cc29e6a5e54a372d92a8b5c3e83d Mon Sep 17 00:00:00 2001 From: shayanfpg9 Date: Fri, 31 Mar 2023 02:23:48 +0430 Subject: [PATCH] use context in document --- client/src/component/Hook/useConfig.jsx | 13 ++++++++++++- client/src/translate/langs/en.json | 2 +- client/src/translate/langs/fa.json | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/src/component/Hook/useConfig.jsx b/client/src/component/Hook/useConfig.jsx index e7a2c13..609a3aa 100644 --- a/client/src/component/Hook/useConfig.jsx +++ b/client/src/component/Hook/useConfig.jsx @@ -36,6 +36,10 @@ export default function useConfig(error = false) { document.title += ` (${params.query})`; break; + case "document": + document.title += " -> /" + (params.action || params.method || ""); + break; + default: break; } @@ -44,8 +48,15 @@ export default function useConfig(error = false) { const setDesc = () => { const DescriptionMeta = document.querySelector("meta[name~='description']"); - if (location !== "info") { + if (location !== "info" && location !== "document") { DescriptionMeta.setAttribute("content", t(`descriptions.${location}`)); + } else if (location === "document") { + DescriptionMeta.setAttribute( + "content", + t(`descriptions.${location}`, { + action: "/" + (params.action || params.method || ""), + }) + ); } else { DescriptionMeta.setAttribute( "content", diff --git a/client/src/translate/langs/en.json b/client/src/translate/langs/en.json index 517e940..7ff2c62 100644 --- a/client/src/translate/langs/en.json +++ b/client/src/translate/langs/en.json @@ -128,7 +128,7 @@ "table": "This is a fantastic periodic table you see atoms with colorful style and you can click to see the details", "TableResult": "You look for a special atom? you can find it here", "info": "Information about {{name}} atom is visible in here:", - "document": "document of Elen Atomic World api, you're in", + "document": "document of Elen Atomic World api, you're in {{action}}", "error": "oh no, i get an error, we can't get anything" } } diff --git a/client/src/translate/langs/fa.json b/client/src/translate/langs/fa.json index 6ab1e5d..90d6a24 100644 --- a/client/src/translate/langs/fa.json +++ b/client/src/translate/langs/fa.json @@ -128,7 +128,7 @@ "table": "یک جدول تناوبی فوق العاده ی رنگی که میتونین با کلیک روی هر اتم اطلاعاتی درباره ی اون کسب کنید", "TableResult": "دنبال اتم خاصی میگری؟\nاینجا میتونی پیداش کنی", "info": "کلی اطلاعات درباره ی اتم {{name}} اینجا موجوده کدومشو میخوای؟", - "document": "مستندات api دنیای اتمی الن", + "document": "مستندات api دنیای اتمی الن شما در {{action}} هستید", "error": "وای، اینجا یه ارور هست، نمیتونیم کاری کنیم..." } }