feat: improve accessibility and SEO (100/100 Lighthouse score)
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 1m27s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 1m27s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Fixes color contrast, canonical URLs, viewport scaling, semantic lists, and resolves 404 errors for manifest/imgproxy.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"defaults": {
|
"defaults": {
|
||||||
"standard": "WCAG2AA",
|
"standard": "WCAG2AA",
|
||||||
"runners": ["axe", "htmlcs"],
|
"runners": ["axe", "htmlcs"],
|
||||||
"ignore": ["color-contrast"],
|
"ignore": [],
|
||||||
"timeout": 50000,
|
"timeout": 50000,
|
||||||
"wait": 1000,
|
"wait": 1000,
|
||||||
"chromeLaunchConfig": {
|
"chromeLaunchConfig": {
|
||||||
|
|||||||
@@ -24,10 +24,17 @@ const inter = Inter({
|
|||||||
variable: '--font-inter',
|
variable: '--font-inter',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export async function generateMetadata(props: {
|
||||||
|
params: Promise<{ locale: string }>;
|
||||||
|
}): Promise<Metadata> {
|
||||||
|
const params = await props.params;
|
||||||
|
const { locale } = params;
|
||||||
|
|
||||||
|
return {
|
||||||
metadataBase: new URL(SITE_URL),
|
metadataBase: new URL(SITE_URL),
|
||||||
|
manifest: '/manifest.webmanifest',
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical: '/',
|
canonical: locale === 'en' ? '/' : `/${locale}`,
|
||||||
languages: {
|
languages: {
|
||||||
de: '/de',
|
de: '/de',
|
||||||
en: '/en',
|
en: '/en',
|
||||||
@@ -40,13 +47,14 @@ export const metadata: Metadata = {
|
|||||||
],
|
],
|
||||||
apple: [{ url: '/apple-touch-icon.png', sizes: '180x180', type: 'image/png' }],
|
apple: [{ url: '/apple-touch-icon.png', sizes: '180x180', type: 'image/png' }],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
width: 'device-width',
|
width: 'device-width',
|
||||||
initialScale: 1,
|
initialScale: 1,
|
||||||
maximumScale: 1,
|
maximumScale: 5,
|
||||||
userScalable: false,
|
userScalable: true,
|
||||||
viewportFit: 'cover',
|
viewportFit: 'cover',
|
||||||
themeColor: '#001a4d',
|
themeColor: '#001a4d',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ export default function Footer() {
|
|||||||
<p className="text-white/80 font-bold group-hover:text-accent transition-colors leading-snug mb-2 text-base md:text-base">
|
<p className="text-white/80 font-bold group-hover:text-accent transition-colors leading-snug mb-2 text-base md:text-base">
|
||||||
{post.title}
|
{post.title}
|
||||||
</p>
|
</p>
|
||||||
<span className="text-xs text-white/40 uppercase tracking-widest">
|
<span className="text-xs text-white/70 uppercase tracking-widest">
|
||||||
{t('readArticle')} →
|
{t('readArticle')} →
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -240,7 +240,7 @@ export default function Footer() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="pt-12 border-t border-white/10 flex flex-col md:flex-row justify-between items-center gap-8 text-white/40 text-xs md:text-sm font-medium">
|
<div className="pt-12 border-t border-white/10 flex flex-col md:flex-row justify-between items-center gap-8 text-white/70 text-xs md:text-sm font-medium">
|
||||||
<p>{t('copyright', { year: currentYear })}</p>
|
<p>{t('copyright', { year: currentYear })}</p>
|
||||||
<div className="flex gap-8">
|
<div className="flex gap-8">
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ export default async function RecentPosts({ locale }: RecentPostsProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-10">
|
<ul className="grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-10 list-none p-0 m-0">
|
||||||
{recentPosts.map((post) => (
|
{recentPosts.map((post) => (
|
||||||
<Link key={post.slug} href={`/${locale}/blog/${post.slug}`} className="group block">
|
<li key={post.slug}>
|
||||||
|
<Link href={`/${locale}/blog/${post.slug}`} className="group block h-full">
|
||||||
<Card
|
<Card
|
||||||
tag="article"
|
tag="article"
|
||||||
className="h-full flex flex-col border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-3xl"
|
className="h-full flex flex-col border-none shadow-lg hover:shadow-2xl transition-all duration-500 rounded-3xl"
|
||||||
@@ -91,8 +92,9 @@ export default async function RecentPosts({ locale }: RecentPostsProps) {
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Link>
|
</Link>
|
||||||
|
</li>
|
||||||
))}
|
))}
|
||||||
</div>
|
</ul>
|
||||||
</Container>
|
</Container>
|
||||||
</Section>
|
</Section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ export default function WhyChooseUs() {
|
|||||||
{t('subtitle')}
|
{t('subtitle')}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="mt-12 space-y-6">
|
<ul className="mt-12 space-y-6 list-none p-0">
|
||||||
{[0, 1, 2, 3].map((i) => (
|
{[0, 1, 2, 3].map((i) => (
|
||||||
<div key={i} className="flex items-center gap-4">
|
<li key={i} className="flex items-center gap-4">
|
||||||
<div className="flex-shrink-0 w-6 h-6 rounded-full bg-accent flex items-center justify-center">
|
<div className="flex-shrink-0 w-6 h-6 rounded-full bg-accent flex items-center justify-center">
|
||||||
<svg
|
<svg
|
||||||
className="w-4 h-4 text-primary-dark"
|
className="w-4 h-4 text-primary-dark"
|
||||||
@@ -40,9 +40,9 @@ export default function WhyChooseUs() {
|
|||||||
<span className="font-bold text-primary-dark text-base md:text-base">
|
<span className="font-bold text-primary-dark text-base md:text-base">
|
||||||
{t(`features.${i}`)}
|
{t(`features.${i}`)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</li>
|
||||||
))}
|
))}
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul className="lg:col-span-8 grid grid-cols-1 md:grid-cols-2 gap-8 order-2 lg:order-1 list-none p-0 m-0">
|
<ul className="lg:col-span-8 grid grid-cols-1 md:grid-cols-2 gap-8 order-2 lg:order-1 list-none p-0 m-0">
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ export default function imgproxyLoader({
|
|||||||
width: number;
|
width: number;
|
||||||
_quality?: number;
|
_quality?: number;
|
||||||
}) {
|
}) {
|
||||||
|
// Skip imgproxy for SVGs as they are vectors and don't benefit from resizing,
|
||||||
|
// and often cause 404s if the source is not correctly resolvable by imgproxy.
|
||||||
|
if (src.toLowerCase().endsWith('.svg')) {
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
// We use the width provided by Next.js for responsive images
|
// We use the width provided by Next.js for responsive images
|
||||||
// Height is set to 0 to maintain aspect ratio
|
// Height is set to 0 to maintain aspect ratio
|
||||||
return getImgproxyUrl(src, {
|
return getImgproxyUrl(src, {
|
||||||
|
|||||||
@@ -58,12 +58,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Navigation": {
|
"Navigation": {
|
||||||
|
"menu": "Menü",
|
||||||
"home": "KLZ Cables Startseite",
|
"home": "KLZ Cables Startseite",
|
||||||
"team": "Team",
|
"team": "Team",
|
||||||
"products": "Produkte",
|
"products": "Produkte",
|
||||||
"blog": "Blog",
|
"blog": "Blog",
|
||||||
"contact": "Kontakt",
|
"contact": "Kontakt",
|
||||||
"toggleMenu": "Menü umschalten"
|
"toggleMenu": "Menü umschalten",
|
||||||
|
"skipToContent": "Zum Inhalt springen"
|
||||||
},
|
},
|
||||||
"Footer": {
|
"Footer": {
|
||||||
"legal": "Rechtliches",
|
"legal": "Rechtliches",
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ export default function middleware(request: NextRequest) {
|
|||||||
pathname.startsWith('/health') ||
|
pathname.startsWith('/health') ||
|
||||||
pathname.includes('/api/og') ||
|
pathname.includes('/api/og') ||
|
||||||
pathname.includes('opengraph-image') ||
|
pathname.includes('opengraph-image') ||
|
||||||
pathname.endsWith('sitemap.xml')
|
pathname.endsWith('sitemap.xml') ||
|
||||||
|
pathname.endsWith('manifest.webmanifest')
|
||||||
) {
|
) {
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
}
|
}
|
||||||
@@ -94,6 +95,6 @@ export default function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: [
|
matcher: [
|
||||||
'/((?!api|_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp|pdf|txt|vcf|xml)$).*)',
|
'/((?!api|_next/static|_next/image|favicon.ico|manifest.webmanifest|.*\\.(?:svg|png|jpg|jpeg|gif|webp|pdf|txt|vcf|xml)$).*)',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
"check:og": "tsx scripts/check-og-images.ts",
|
"check:og": "tsx scripts/check-og-images.ts",
|
||||||
"check:mdx": "node scripts/validate-mdx.mjs",
|
"check:mdx": "node scripts/validate-mdx.mjs",
|
||||||
"check:a11y": "start-server-and-test start http://localhost:3000 'pa11y-ci'",
|
"check:a11y": "start-server-and-test start http://localhost:3000 'pa11y-ci'",
|
||||||
|
"check:wcag": "tsx ./scripts/wcag-sitemap.ts",
|
||||||
"cms:branding:local": "DIRECTUS_URL=${DIRECTUS_URL:-http://cms.klz.localhost} npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
"cms:branding:local": "DIRECTUS_URL=${DIRECTUS_URL:-http://cms.klz.localhost} npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
||||||
"cms:branding:testing": "DIRECTUS_URL=https://cms.testing.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
"cms:branding:testing": "DIRECTUS_URL=https://cms.testing.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
||||||
"cms:branding:staging": "DIRECTUS_URL=https://cms.staging.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
"cms:branding:staging": "DIRECTUS_URL=https://cms.staging.klz-cables.com npx tsx --env-file=.env scripts/setup-directus-branding.ts",
|
||||||
|
|||||||
163
scripts/wcag-sitemap.ts
Normal file
163
scripts/wcag-sitemap.ts
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WCAG Audit Script
|
||||||
|
*
|
||||||
|
* 1. Fetches sitemap.xml from the target URL
|
||||||
|
* 2. Extracts all URLs
|
||||||
|
* 3. Runs pa11y-ci on those URLs
|
||||||
|
*/
|
||||||
|
|
||||||
|
const targetUrl =
|
||||||
|
process.argv[2] || process.env.NEXT_PUBLIC_BASE_URL || 'https://testing.klz-cables.com';
|
||||||
|
const limit = process.env.PAGESPEED_LIMIT ? parseInt(process.env.PAGESPEED_LIMIT) : 20;
|
||||||
|
const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'klz2026';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log(`\n🚀 Starting WCAG Audit for: ${targetUrl}`);
|
||||||
|
console.log(`📊 Limit: ${limit} pages\n`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Fetch Sitemap
|
||||||
|
const sitemapUrl = `${targetUrl.replace(/\/$/, '')}/sitemap.xml`;
|
||||||
|
console.log(`📥 Fetching sitemap from ${sitemapUrl}...`);
|
||||||
|
|
||||||
|
const response = await axios.get(sitemapUrl, {
|
||||||
|
headers: {
|
||||||
|
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
|
||||||
|
},
|
||||||
|
validateStatus: (status) => status < 400,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data, { xmlMode: true });
|
||||||
|
let urls = $('url loc')
|
||||||
|
.map((i, el) => $(el).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Cleanup, filter and normalize domains to targetUrl
|
||||||
|
const urlPattern = /https?:\/\/[^\/]+/;
|
||||||
|
urls = [...new Set(urls)]
|
||||||
|
.filter((u) => u.startsWith('http'))
|
||||||
|
.map((u) => u.replace(urlPattern, targetUrl.replace(/\/$/, '')))
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
console.log(`✅ Found ${urls.length} URLs in sitemap.`);
|
||||||
|
|
||||||
|
if (urls.length === 0) {
|
||||||
|
console.error('❌ No URLs found in sitemap. Is the site up?');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urls.length > limit) {
|
||||||
|
console.log(
|
||||||
|
`⚠️ Too many pages (${urls.length}). Limiting to ${limit} representative pages.`,
|
||||||
|
);
|
||||||
|
const home = urls.filter((u) => u.endsWith('/de') || u.endsWith('/en') || u === targetUrl);
|
||||||
|
const others = urls.filter((u) => !home.includes(u));
|
||||||
|
urls = [...home, ...others.slice(0, limit - home.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`🧪 Pages to be tested:`);
|
||||||
|
urls.forEach((u) => console.log(` - ${u}`));
|
||||||
|
|
||||||
|
// 2. Prepare pa11y-ci config
|
||||||
|
const baseConfigPath = path.join(process.cwd(), '.pa11yci.json');
|
||||||
|
let baseConfig: any = { defaults: {} };
|
||||||
|
if (fs.existsSync(baseConfigPath)) {
|
||||||
|
baseConfig = JSON.parse(fs.readFileSync(baseConfigPath, 'utf8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract domain for cookie
|
||||||
|
const urlObj = new URL(targetUrl);
|
||||||
|
const domain = urlObj.hostname;
|
||||||
|
|
||||||
|
// Update config with discovered URLs and gatekeeper cookie
|
||||||
|
const tempConfig = {
|
||||||
|
...baseConfig,
|
||||||
|
defaults: {
|
||||||
|
...baseConfig.defaults,
|
||||||
|
actions: [
|
||||||
|
`set cookie klz_gatekeeper_session=${gatekeeperPassword} domain=${domain} path=/`,
|
||||||
|
...(baseConfig.defaults?.actions || []),
|
||||||
|
],
|
||||||
|
timeout: 60000, // Increase timeout for slower pages
|
||||||
|
},
|
||||||
|
urls: urls,
|
||||||
|
};
|
||||||
|
|
||||||
|
const tempConfigPath = path.join(process.cwd(), '.pa11yci.temp.json');
|
||||||
|
const reportPath = path.join(process.cwd(), '.pa11yci-report.json');
|
||||||
|
fs.writeFileSync(tempConfigPath, JSON.stringify(tempConfig, null, 2));
|
||||||
|
|
||||||
|
// 3. Execute pa11y-ci
|
||||||
|
console.log(`\n💻 Executing pa11y-ci...`);
|
||||||
|
const pa11yCommand = `npx pa11y-ci --config .pa11yci.temp.json --reporter json > .pa11yci-report.json`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
execSync(pa11yCommand, {
|
||||||
|
encoding: 'utf8',
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
// pa11y-ci exits with non-zero if issues are found, which is expected
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Summarize Results
|
||||||
|
if (fs.existsSync(reportPath)) {
|
||||||
|
const reportData = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
|
||||||
|
console.log(`\n📊 WCAG Audit Summary:\n`);
|
||||||
|
|
||||||
|
const summaryTable = Object.keys(reportData.results).map((url) => {
|
||||||
|
const results = reportData.results[url];
|
||||||
|
const errors = results.filter((r: any) => r.type === 'error').length;
|
||||||
|
const warnings = results.filter((r: any) => r.type === 'warning').length;
|
||||||
|
const notices = results.filter((r: any) => r.type === 'notice').length;
|
||||||
|
|
||||||
|
// Clean URL for display
|
||||||
|
const displayUrl = url.replace(targetUrl, '') || '/';
|
||||||
|
|
||||||
|
return {
|
||||||
|
URL: displayUrl.length > 50 ? displayUrl.substring(0, 47) + '...' : displayUrl,
|
||||||
|
Errors: errors,
|
||||||
|
Warnings: warnings,
|
||||||
|
Notices: notices,
|
||||||
|
Status: errors === 0 ? '✅' : '❌',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
console.table(summaryTable);
|
||||||
|
|
||||||
|
const totalErrors = summaryTable.reduce((acc, curr) => acc + curr.Errors, 0);
|
||||||
|
const totalPages = summaryTable.length;
|
||||||
|
const cleanPages = summaryTable.filter((p) => p.Errors === 0).length;
|
||||||
|
|
||||||
|
console.log(`\n📈 Result: ${cleanPages}/${totalPages} pages are error-free.`);
|
||||||
|
if (totalErrors > 0) {
|
||||||
|
console.log(` Total Errors discovered: ${totalErrors}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n✨ WCAG Audit completed!`);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error(`\n❌ Error during WCAG Audit:`);
|
||||||
|
if (axios.isAxiosError(error)) {
|
||||||
|
console.error(`Status: ${error.response?.status}`);
|
||||||
|
console.error(`URL: ${error.config?.url}`);
|
||||||
|
} else {
|
||||||
|
console.error(error.message);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
} finally {
|
||||||
|
// Clean up temp files
|
||||||
|
['.pa11yci.temp.json', '.pa11yci-report.json'].forEach((f) => {
|
||||||
|
const p = path.join(process.cwd(), f);
|
||||||
|
if (fs.existsSync(p)) fs.unlinkSync(p);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
Reference in New Issue
Block a user