Skip to content

Commit a5af9f0

Browse files
🐛(frontend) avoid documents indexing in search engine
Some documents are available publicly (without being logged) and may thus end-up being indexed by search engine.
1 parent d715e7b commit a5af9f0

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to
2121
- 🐛(i18n) same frontend and backend language using shared cookies #365
2222
- 🐛(frontend) add default toolbar buttons #355
2323
- 🐛(frontend) throttle error correctly display #378
24+
- 🐛(frontend) (frontend) avoid documents indexing in search engine #372
2425

2526
## Removed
2627

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ test.describe('Doc Routing', () => {
77
await page.goto('/');
88
});
99

10+
test('Check the presence of the meta tag noindex', async ({ page }) => {
11+
const buttonCreateHomepage = page.getByRole('button', {
12+
name: 'Create a new document',
13+
});
14+
15+
await expect(buttonCreateHomepage).toBeVisible();
16+
await buttonCreateHomepage.click();
17+
await expect(
18+
page.getByRole('button', {
19+
name: 'Share',
20+
}),
21+
).toBeVisible();
22+
const metaDescription = page.locator('meta[name="robots"]');
23+
await expect(metaDescription).toHaveAttribute('content', 'noindex');
24+
});
25+
1026
test('checks alias docs url with homepage', async ({ page }) => {
1127
await expect(page).toHaveURL('/');
1228

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Loader } from '@openfun/cunningham-react';
2+
import Head from 'next/head';
23
import { useRouter as useNavigate } from 'next/navigation';
34
import { useRouter } from 'next/router';
45
import { useEffect, useState } from 'react';
@@ -21,9 +22,14 @@ export function DocLayout() {
2122
}
2223

2324
return (
24-
<MainLayout withoutFooter>
25-
<DocPage id={id} />
26-
</MainLayout>
25+
<>
26+
<Head>
27+
<meta name="robots" content="noindex" />
28+
</Head>
29+
<MainLayout withoutFooter>
30+
<DocPage id={id} />
31+
</MainLayout>
32+
</>
2733
);
2834
}
2935

0 commit comments

Comments
 (0)