Skip to content

Commit

Permalink
Dynamic page title based on error kind (#1034)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Osbourne <shane.osbourne8@gmail.com>
mgurgel and shakyShane authored Oct 10, 2024
1 parent 48077a1 commit 347eb3f
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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,23 @@ export function SpecialErrorView() {
)
}

function PageTitle() {
const { kind } = useErrorData()
const { t } = useTypedTranslation()

useEffect(() => {
switch(kind) {
case 'phishing':
document.title = t('phishingPageHeading')
break;
default:
document.title = t('sslPageHeading')
}
}, [kind, t])

return null
}

export function App() {
const { messaging } = useMessaging()

@@ -40,6 +59,7 @@ export function App() {

return (
<main className={styles.main}>
<PageTitle />
<ErrorBoundary didCatch={didCatch} fallback={<ErrorFallback />}>
<SpecialErrorView />
<WillThrow/>
2 changes: 1 addition & 1 deletion packages/special-pages/pages/special-error/src/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>SSL Error Page</title>
<title>Error</title>
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="js/inline.js"></script>

0 comments on commit 347eb3f

Please sign in to comment.