import React from 'react';
import { useLocation } from 'react-router-dom';
import { BookOpen } from 'lucide-react';
import { getDocUrl } from '@/config/docRoutes';
import { Button } from '@/components/ui/button';

export function DocLink() {
    const location = useLocation();
    const docUrl = getDocUrl(location.pathname);

    if (!docUrl) return null;

    return (
        <Button
            variant="ghost"
            size="icon"
            className="h-8 w-8 ml-2 text-muted-foreground hover:text-primary"
            asChild
        >
            <a href={docUrl} target="_blank" rel="noopener noreferrer" title="View Documentation">
                <BookOpen className="h-4 w-4" />
                <span className="sr-only">View Documentation</span>
            </a>
        </Button>
    );
}
