Skip to content

Commit d1993a6

Browse files
arbrandesclaude
andcommitted
fix: set document title via Helmet on the not-found route
NotFoundPage was the only authn route child without a <Helmet> block, so /authn/notfound kept whatever title the previous page set. Add the title following the per-page pattern from frontend-base ADR 0015. Refs openedx/frontend-base#250. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 65c13df commit d1993a6

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
import { FormattedMessage } from '@openedx/frontend-base';
1+
import { FormattedMessage, getSiteConfig, useIntl } from '@openedx/frontend-base';
2+
import { Helmet } from 'react-helmet';
23

3-
const NotFoundPage = () => (
4-
<div className="container-fluid d-flex py-5 justify-content-center align-items-start text-center">
5-
<p className="my-0 py-5 text-muted mw-32em">
6-
<FormattedMessage
7-
id="error.notfound.message"
8-
defaultMessage="The page you're looking for is unavailable or there's an error in the URL. Please check the URL and try again."
9-
description="error message when a page does not exist"
10-
/>
11-
</p>
12-
</div>
13-
);
4+
import messages from './messages';
5+
6+
const NotFoundPage = () => {
7+
const { formatMessage } = useIntl();
8+
return (
9+
<div className="container-fluid d-flex py-5 justify-content-center align-items-start text-center">
10+
<Helmet>
11+
<title>
12+
{formatMessage(messages['error.notfound.page.title'], {
13+
siteName: getSiteConfig().siteName,
14+
})}
15+
</title>
16+
</Helmet>
17+
<p className="my-0 py-5 text-muted mw-32em">
18+
<FormattedMessage
19+
id="error.notfound.message"
20+
defaultMessage="The page you're looking for is unavailable or there's an error in the URL. Please check the URL and try again."
21+
description="error message when a page does not exist"
22+
/>
23+
</p>
24+
</div>
25+
);
26+
};
1427

1528
export default NotFoundPage;

src/common-components/messages.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { defineMessages } from '@openedx/frontend-base';
22

33
const messages = defineMessages({
4+
// not found page
5+
'error.notfound.page.title': {
6+
id: 'error.notfound.page.title',
7+
defaultMessage: 'Page Not Found | {siteName}',
8+
description: 'Document title for the page-not-found page',
9+
},
410
// institution login strings
511
'institution.login.page.sub.heading': {
612
id: 'institution.login.page.sub.heading',

0 commit comments

Comments
 (0)