🥅(frontend) improve meta 401 page

Add better meta for the 401 page.
This commit is contained in:
Anthony LC
2025-09-17 14:53:21 +02:00
parent d8c9283dd1
commit b773f09792
2 changed files with 41 additions and 23 deletions

View File

@@ -93,6 +93,12 @@ test.describe('Doc Routing', () => {
await expect(page.getByText('Log in to access the document.')).toBeVisible({ await expect(page.getByText('Log in to access the document.')).toBeVisible({
timeout: 10000, timeout: 10000,
}); });
await expect(page.locator('meta[name="robots"]')).toHaveAttribute(
'content',
'noindex',
);
await expect(page).toHaveTitle(/401 Unauthorized - Docs/);
}); });
}); });

View File

@@ -1,4 +1,5 @@
import { Button } from '@openfun/cunningham-react'; import { Button } from '@openfun/cunningham-react';
import Head from 'next/head';
import Image from 'next/image'; import Image from 'next/image';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { ReactElement, useEffect } from 'react'; import { ReactElement, useEffect } from 'react';
@@ -22,32 +23,43 @@ const Page: NextPageWithLayout = () => {
}, [authenticated, replace]); }, [authenticated, replace]);
return ( return (
<Box <>
$align="center" <Head>
$margin="auto" <meta name="robots" content="noindex" />
$gap="1rem" <title>{`${t('401 Unauthorized')} - ${t('Docs')}`}</title>
$padding={{ bottom: '2rem' }} <meta
> property="og:title"
<Image content={`${t('401 Unauthorized')} - ${t('Docs')}`}
className="c__image-system-filter" key="title"
src={img401} />
alt={t('Image 401')} </Head>
style={{ <Box
maxWidth: '100%', $align="center"
height: 'auto', $margin="auto"
}} $gap="1rem"
/> $padding={{ bottom: '2rem' }}
>
<Image
className="c__image-system-filter"
src={img401}
alt={t('Image 401')}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
<Box $align="center" $gap="0.8rem"> <Box $align="center" $gap="0.8rem">
<Text as="p" $textAlign="center" $maxWidth="350px" $theme="primary"> <Text as="p" $textAlign="center" $maxWidth="350px" $theme="primary">
{t('Log in to access the document.')} {t('Log in to access the document.')}
</Text> </Text>
<Button onClick={() => gotoLogin(false)} aria-label={t('Login')}> <Button onClick={() => gotoLogin(false)} aria-label={t('Login')}>
{t('Login')} {t('Login')}
</Button> </Button>
</Box>
</Box> </Box>
</Box> </>
); );
}; };