From 0b837127f7f67284137655a365e71998bd1cfded Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 12 Sep 2024 14:25:32 +0100 Subject: [PATCH 1/2] Dynamic page title based on error kind --- .../special-error/app/components/App.jsx | 26 ++++++++++++++++++- .../pages/special-error/src/index.html | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/special-pages/pages/special-error/app/components/App.jsx b/packages/special-pages/pages/special-error/app/components/App.jsx index e9de0b1d7..b1c58de2c 100644 --- a/packages/special-pages/pages/special-error/app/components/App.jsx +++ b/packages/special-pages/pages/special-error/app/components/App.jsx @@ -1,9 +1,11 @@ import { h } from "preact"; -import { useState } from "preact/hooks"; +import { useEffect, useState } from "preact/hooks"; import { useEnv } from "../../../../shared/components/EnvironmentProvider"; import { useMessaging } from "../providers/MessagingProvider"; import { ErrorBoundary } from '../../../../shared/components/ErrorBoundary' import { ErrorFallback } from "./ErrorFallback"; +import { useTypedTranslation } from '../types' +import { useErrorData } from "../providers/SpecialErrorProvider"; import { Warning } from "./Warning"; import { AdvancedInfo } from "./AdvancedInfo"; @@ -26,6 +28,27 @@ export function SpecialErrorView() { ) } +function PageTitle() { + const { kind } = useErrorData() + const { t } = useTypedTranslation() + + useEffect(() => { + let title + + switch(kind) { + case 'phishing': + title = t('phishingPageHeading') + break; + default: + title = t('sslPageHeading') + } + + document.title = title + }, []) + + return null +} + export function App() { const { messaging } = useMessaging() @@ -40,6 +63,7 @@ export function App() { return (
+ }> diff --git a/packages/special-pages/pages/special-error/src/index.html b/packages/special-pages/pages/special-error/src/index.html index 98dd81b85..5c977b36f 100644 --- a/packages/special-pages/pages/special-error/src/index.html +++ b/packages/special-pages/pages/special-error/src/index.html @@ -1,7 +1,7 @@ - SSL Error Page + Error From 032af7e5313c47fd6d95c95bb7b827f5ed5f4b3e Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Fri, 13 Sep 2024 10:23:38 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Adopted=20Shane=E2=80=99s=20suggestion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Shane Osbourne --- .../pages/special-error/app/components/App.jsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/special-pages/pages/special-error/app/components/App.jsx b/packages/special-pages/pages/special-error/app/components/App.jsx index b1c58de2c..b1d2a64d7 100644 --- a/packages/special-pages/pages/special-error/app/components/App.jsx +++ b/packages/special-pages/pages/special-error/app/components/App.jsx @@ -33,18 +33,14 @@ function PageTitle() { const { t } = useTypedTranslation() useEffect(() => { - let title - switch(kind) { case 'phishing': - title = t('phishingPageHeading') + document.title = t('phishingPageHeading') break; default: - title = t('sslPageHeading') + document.title = t('sslPageHeading') } - - document.title = title - }, []) + }, [kind, t]) return null }