docs/docs/broken-link-handling.md
This document describes the system for handling broken links in the CopilotKit documentation.
The documentation now includes several mechanisms to provide a better user experience when links are broken:
app/not-found.tsx)The 404 page now provides:
components/react/broken-link-handler.tsx)Components for handling broken links:
BrokenLinkHandler - Wraps links with validationEnhancedNavigationLink - Enhanced navigation link with validationlib/link-validation.ts)Utilities for validating links and providing suggestions:
validateLink() - Validates if a link is brokengenerateSuggestions() - Creates suggestions for broken linkscreateLinkSuggestion() - Creates suggestion objectsmiddleware.ts)Handles automatic redirects for common broken link patterns:
npm run check-links
This will:
To add new redirects, update the redirects object in middleware.ts:
const redirects: Record<string, string> = {
"/old-path": "/new-path",
// Add more redirects here
};
import { BrokenLinkHandler, EnhancedNavigationLink } from '@/components/react/broken-link-handler';
// For basic link handling
<BrokenLinkHandler href="/some-link" fallbackHref="/">
Link Text
</BrokenLinkHandler>
// For enhanced navigation
<EnhancedNavigationLink href="/some-link">
Link Text
</EnhancedNavigationLink>
npm run check-links regularly during developmentTo debug link validation, you can add console logs to the validation functions or run the link checker with verbose output.