Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes, 404 and error pages inside the shell, plus per-page SEO from a single page registry (canonical URLs, Open Graph image, JSON-LD, generated sitemap.xml and robots.txt). Theme tokens and recipes replace repeated styling, the hero loads only the active and neighbouring slides, and the e-mail address is joined in the browser to keep it out of the HTML and bundle. Adds Vitest with property-based (fast-check) and axe tests, ESLint, security headers for dev and preview, Lighthouse CI and a `pnpm check` script that runs all quality gates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import { screen, within } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import siteContent from '@/content/siteContent';
|
||||
import type { SiteContent } from '@/content/types';
|
||||
import { axeResults } from '@/test/axe';
|
||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||
import Footer from './Footer';
|
||||
|
||||
const renderFooter = (content: SiteContent = siteContent, path = '/') =>
|
||||
renderWithProviders(<Footer content={content} />, { path });
|
||||
|
||||
describe('Footer', () => {
|
||||
it('toont merk, socials en contact met h2-koppen', async () => {
|
||||
const { container } = await renderFooter();
|
||||
expect(
|
||||
screen.getByRole('img', { name: 'Andrea Slop Fotografie' }),
|
||||
).toBeInTheDocument();
|
||||
// Regelafbreking uit de content blijft in de tekst staan
|
||||
expect(
|
||||
screen.getByText(siteContent.footerIntro, {
|
||||
normalizer: (text) => text,
|
||||
}),
|
||||
).toHaveStyle({ whiteSpace: 'pre-line' });
|
||||
const headings = screen.getAllByRole('heading', { level: 2 });
|
||||
// Naam in gewone schrijfwijze, los van de CSS-hoofdletters
|
||||
expect(headings.map((h) => h.getAttribute('aria-label'))).toEqual([
|
||||
'Socials',
|
||||
'Contact',
|
||||
]);
|
||||
expect(headings.map((h) => h.textContent)).toEqual([
|
||||
'Socials',
|
||||
'Contact',
|
||||
]);
|
||||
expect(await axeResults(container)).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('opent socials veilig in een nieuw tabblad en meldt dat', async () => {
|
||||
await renderFooter();
|
||||
const link = screen.getByRole('link', {
|
||||
name: 'Facebook (opent in nieuw tabblad)',
|
||||
});
|
||||
expect(link).toHaveAttribute('target', '_blank');
|
||||
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
|
||||
expect(link).toHaveAttribute('href', siteContent.socials[0].href);
|
||||
});
|
||||
|
||||
it('voegt het e-mailadres pas bij het tonen samen', async () => {
|
||||
await renderFooter();
|
||||
const link = screen.getByTestId('footer-email-link');
|
||||
expect(link).toHaveAttribute('href', 'mailto:info@andreaslop.nl');
|
||||
expect(link).toHaveTextContent('info@andreaslop.nl');
|
||||
});
|
||||
|
||||
it('toont het huidige jaar', async () => {
|
||||
await renderFooter();
|
||||
expect(
|
||||
screen.getByText(
|
||||
`© ${new Date().getFullYear()} Andrea Slop Fotografie`,
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('heeft een footermenu dat de actieve pagina markeert', async () => {
|
||||
await renderFooter(siteContent, '/portfolio');
|
||||
const nav = screen.getByRole('navigation', { name: 'Footermenu' });
|
||||
const links = within(nav).getAllByRole('link');
|
||||
expect(links.map((l) => l.textContent)).toEqual([
|
||||
'Portfolio',
|
||||
'Soorten fotoshoots',
|
||||
'Contact',
|
||||
'Privacyverklaring',
|
||||
]);
|
||||
expect(links[0]).toHaveAttribute('aria-current', 'page');
|
||||
expect(links[1]).not.toHaveAttribute('aria-current');
|
||||
});
|
||||
|
||||
it('laat lege kolommen weg', async () => {
|
||||
await renderFooter({
|
||||
...siteContent,
|
||||
socials: [{ platform: 'facebook', href: '' }],
|
||||
email: { user: '', domain: 'andreaslop.nl' },
|
||||
});
|
||||
expect(screen.queryByRole('heading', { name: 'Socials' })).toBeNull();
|
||||
expect(screen.queryByRole('heading', { name: 'Contact' })).toBeNull();
|
||||
expect(screen.queryByTestId('footer-email-link')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
import {
|
||||
Box,
|
||||
chakra,
|
||||
Container,
|
||||
Flex,
|
||||
Grid,
|
||||
Image,
|
||||
Text,
|
||||
VisuallyHidden,
|
||||
} from '@chakra-ui/react';
|
||||
import socialPlatforms from '@/content/socialPlatforms';
|
||||
import type { SiteContent } from '@/content/types';
|
||||
import { copyrightLine } from '@/lib/copyrightLine';
|
||||
import { emailAddress } from '@/lib/emailAddress';
|
||||
import { visibleSocials } from '@/lib/visibleSocials';
|
||||
import { footerNav } from '@/navigation';
|
||||
import RouterLink from '../RouterLink';
|
||||
import FooterColumn from './FooterColumn';
|
||||
import FooterLink from './FooterLink';
|
||||
|
||||
// Images
|
||||
import logoDark from '../../assets/logo-dark.png';
|
||||
|
||||
type FooterProps = {
|
||||
content: SiteContent;
|
||||
};
|
||||
|
||||
// Footer uit het design (FR-05): merk, socials en contact, met daaronder de
|
||||
// copyright en het footermenu. Een lege kolom valt weg (BR-FOOT-01).
|
||||
export default function Footer({ content }: FooterProps) {
|
||||
const socials = visibleSocials(content.socials);
|
||||
// Pas hier samengevoegd, zodat het adres nergens letterlijk staat
|
||||
const email = emailAddress(content.email);
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
return (
|
||||
<Box
|
||||
as="footer"
|
||||
bg="paper.alt"
|
||||
borderTopWidth="1px"
|
||||
borderTopColor="line"
|
||||
pt="clamp(3.5rem, 7vw, 6rem)"
|
||||
>
|
||||
<Container>
|
||||
<Grid
|
||||
templateColumns={{
|
||||
base: '1fr',
|
||||
md: 'repeat(2, 1fr)',
|
||||
lg: '1.2fr 1fr 1fr',
|
||||
}}
|
||||
gap="clamp(2rem, 5vw, 4rem)"
|
||||
pb="clamp(2.5rem, 5vw, 4rem)"
|
||||
>
|
||||
{/* Merk: op mobiel gecentreerd onder elkaar, vanaf tablet
|
||||
het logo met de tekst ernaast */}
|
||||
<Flex
|
||||
direction={{ base: 'column', md: 'row' }}
|
||||
alignItems="center"
|
||||
alignSelf="start"
|
||||
gap={5}
|
||||
textAlign={{ base: 'center', md: 'start' }}
|
||||
>
|
||||
<Image
|
||||
src={logoDark}
|
||||
alt="Andrea Slop Fotografie"
|
||||
htmlWidth={500}
|
||||
htmlHeight={500}
|
||||
w={{ base: '150px', md: '110px' }}
|
||||
h="auto"
|
||||
flexShrink={0}
|
||||
loading="lazy"
|
||||
/>
|
||||
{/* Regelafbrekingen uit de content blijven staan */}
|
||||
<Text color="ink.soft" whiteSpace="pre-line">
|
||||
{content.footerIntro}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
{socials.length > 0 && (
|
||||
<FooterColumn title="Socials">
|
||||
{socials.map((social) => (
|
||||
<chakra.li key={social.platform}>
|
||||
<FooterLink
|
||||
href={social.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
data-testid={`footer-social-${social.platform}`}
|
||||
>
|
||||
{/* Spatie buiten de verborgen tekst, anders
|
||||
valt hij weg uit de voorgelezen naam */}
|
||||
{socialPlatforms[social.platform].name}{' '}
|
||||
<VisuallyHidden>
|
||||
(opent in nieuw tabblad)
|
||||
</VisuallyHidden>
|
||||
</FooterLink>
|
||||
</chakra.li>
|
||||
))}
|
||||
</FooterColumn>
|
||||
)}
|
||||
|
||||
{email && (
|
||||
<FooterColumn title="Contact">
|
||||
<chakra.li>
|
||||
<FooterLink
|
||||
href={`mailto:${email}`}
|
||||
data-testid="footer-email-link"
|
||||
>
|
||||
{email}
|
||||
</FooterLink>
|
||||
</chakra.li>
|
||||
</FooterColumn>
|
||||
)}
|
||||
</Grid>
|
||||
|
||||
<Flex
|
||||
direction={{ base: 'column', md: 'row' }}
|
||||
alignItems="center"
|
||||
justifyContent="space-between"
|
||||
gap={{ base: 2, md: 6 }}
|
||||
py={6}
|
||||
borderTopWidth="1px"
|
||||
borderTopColor="line"
|
||||
textAlign={{ base: 'center', md: 'start' }}
|
||||
>
|
||||
<Text fontSize="sm" color="ink.soft">
|
||||
{copyrightLine(year)}
|
||||
</Text>
|
||||
<chakra.nav aria-label="Footermenu">
|
||||
<Flex
|
||||
as="ul"
|
||||
listStyleType="none"
|
||||
wrap="wrap"
|
||||
justifyContent="center"
|
||||
columnGap={6}
|
||||
>
|
||||
{footerNav.map((item) => (
|
||||
<chakra.li key={item.to}>
|
||||
<FooterLink asChild>
|
||||
<RouterLink
|
||||
to={item.to}
|
||||
data-testid={`footer-nav-${item.to.slice(1)}`}
|
||||
>
|
||||
{item.label}
|
||||
</RouterLink>
|
||||
</FooterLink>
|
||||
</chakra.li>
|
||||
))}
|
||||
</Flex>
|
||||
</chakra.nav>
|
||||
</Flex>
|
||||
</Container>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Box, Heading, Stack } from '@chakra-ui/react';
|
||||
|
||||
type FooterColumnProps = {
|
||||
title: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
// Kolom in de footer: kopje als label, daaronder een lijst. De kop is een h2,
|
||||
// want de kolommen zijn hoofdsecties van de pagina (BR-SEO-09).
|
||||
export default function FooterColumn({ title, children }: FooterColumnProps) {
|
||||
return (
|
||||
<Box>
|
||||
<Heading
|
||||
as="h2"
|
||||
// Mobiele schermlezers lezen de CSS-hoofdletters ("SOCIALS") als
|
||||
// afkorting; het label geeft ze het woord in gewone schrijfwijze
|
||||
aria-label={title}
|
||||
textStyle="eyebrow"
|
||||
fontFamily="body"
|
||||
color="ink.soft"
|
||||
mb={{ base: 2, lg: 4 }}
|
||||
>
|
||||
{title}
|
||||
</Heading>
|
||||
<Stack as="ul" listStyleType="none" gap={{ base: 0, lg: 2 }}>
|
||||
{children}
|
||||
</Stack>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Link, type LinkProps } from '@chakra-ui/react';
|
||||
|
||||
// Link in de footer: de rustige `subtle`-stijl, en op touch minimaal 44px
|
||||
// hoog als klikdoel (BR-RWD-04)
|
||||
export default function FooterLink(props: LinkProps) {
|
||||
return (
|
||||
<Link
|
||||
variant="subtle"
|
||||
minH={{ base: '44px', lg: 'auto' }}
|
||||
fontSize="sm"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user