Skip to content

Commit 48d3738

Browse files
committed
✨(frontend) update meta title for docs page
We update the meta title for the docs page with the title of the document. It will be easier for the user to identify the document in their browser tab, in their bookmarks and history.
1 parent 92102e4 commit 48d3738

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to
1414
- ✨Add image attachments with access control
1515
- ✨(frontend) Upload image to a document #211
1616
- ✨(frontend) Summary #223
17+
- ✨(frontend) update meta title for docs page #231
1718

1819
## Changed
1920

src/frontend/apps/e2e/__tests__/app-impress/doc-create.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ test.describe('Doc Create', () => {
5555
true,
5656
);
5757

58+
expect(await page.locator('title').textContent()).toMatch(
59+
/My new doc - Docs/,
60+
);
61+
5862
const header = page.locator('header').first();
5963
await header.locator('h2').getByText('Docs').click();
6064

src/frontend/apps/impress/src/pages/_app.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) {
2121
<>
2222
<Head>
2323
<title>{t('Docs')}</title>
24-
<meta name="description" content={t('Docs Description')} />
24+
<meta
25+
name="description"
26+
content={t(
27+
'Docs: Your new companion to collaborate on documents efficiently, intuitively, and securely.',
28+
)}
29+
/>
2530
<link rel="icon" href="/favicon.ico" sizes="any" />
2631
</Head>
2732
<AppProvider>{getLayout(<Component {...pageProps} />)}</AppProvider>

src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Loader } from '@openfun/cunningham-react';
22
import { useRouter as useNavigate } from 'next/navigation';
33
import { useRouter } from 'next/router';
4+
import { useEffect } from 'react';
45

56
import { Box, Text } from '@/components';
67
import { TextErrors } from '@/components/TextErrors';
@@ -33,6 +34,12 @@ const DocPage = ({ id }: DocProps) => {
3334
const { data: doc, isLoading, isError, error } = useDoc({ id });
3435
const navigate = useNavigate();
3536

37+
useEffect(() => {
38+
if (doc?.title) {
39+
document.title = `${doc.title} - Docs`;
40+
}
41+
}, [doc?.title]);
42+
3643
if (isError && error) {
3744
if (error.status === 404) {
3845
navigate.replace(`/404`);

0 commit comments

Comments
 (0)