fix(web): UX/a11y polish + middleware metadata route fix
- footer.tsx: Discord link → canonical discord.gg/PUwSMR9XNk (was outdated invite that 404'd). - [locale]/layout.tsx: hooks count 40 → 54 (matches AGENTS.md). - lib/stats.ts:88: drop '!' non-null assertion; use '??' fallback. Removes the only '!' in packages/web (project rule). - nav-header.tsx: hamburger Button size='icon' → explicit h-11 w-11; mobile drawer links min-h-11 px-3 rounded-md. WCAG 2.5.5 tap target 44x44 minimum. - install-command.tsx: copy button h-8 w-8 → h-11 w-11 (was 32px, below WCAG). Icon stays 16x16; padding fills to 44. - middleware.ts: matcher excludes opengraph-image, twitter-image, icon, apple-icon, manifest.webmanifest, robots.txt, sitemap.xml. Previously next-intl redirected /opengraph-image → /en/opengraph-image breaking OG previews for crawlers that hit the unlocalized path.
This commit is contained in:
@@ -28,7 +28,7 @@ function getInstallationDocsPath(pathname: string): string | null {
|
||||
return locale ? `/${locale}/docs` : "/docs"
|
||||
}
|
||||
|
||||
export default function middleware(request: NextRequest) {
|
||||
export default function middleware(request: NextRequest): NextResponse {
|
||||
const forwardedHost = request.headers.get("x-forwarded-host")
|
||||
const requestHost = request.headers.get("host")
|
||||
const hostname = (forwardedHost ?? requestHost ?? request.nextUrl.hostname).split(":")[0]
|
||||
@@ -59,7 +59,15 @@ export default function middleware(request: NextRequest) {
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/",
|
||||
"/((?!api|_next|_vercel|.*\\..*).+)",
|
||||
/*
|
||||
* Match everything except:
|
||||
* - api routes
|
||||
* - Next.js internals (_next, _vercel)
|
||||
* - Next.js file-based metadata routes (opengraph-image, twitter-image, icon, apple-icon, manifest, robots, sitemap)
|
||||
* These serve images / JSON / XML directly and must NOT be redirected by i18n.
|
||||
* - Any path containing a dot (favicon.ico, *.webp, *.png, etc.)
|
||||
*/
|
||||
"/((?!api|_next|_vercel|opengraph-image|twitter-image|icon|apple-icon|manifest\\.webmanifest|robots\\.txt|sitemap\\.xml|.*\\..*).+)",
|
||||
"/installation.md",
|
||||
"/:locale(en|ko|ja|zh)/installation.md",
|
||||
"/docs/installation.md",
|
||||
|
||||
Reference in New Issue
Block a user