import Link from "next/link";
import type { Guide } from "@/lib/guides";
import { getGuide } from "@/lib/guides";

export default function ContextualGuideLink({ guide, sectionHeading }: { guide: Guide; sectionHeading: string }) {
  if (guide.contextualLink.afterSection !== sectionHeading) return null;

  const relatedGuide = getGuide(guide.contextualLink.guideSlug);
  if (!relatedGuide) return null;

  return (
    <p className="mt-5 border-l-2 border-[#0d7a57]/30 pl-4 text-base leading-relaxed text-ink-soft">
      {guide.contextualLink.lead}{" "}
      <Link href={`/ratgeber/${relatedGuide.slug}`} className="font-semibold text-[#0d7a57] underline decoration-[#0d7a57]/30 underline-offset-4 hover:text-[#095c41]">
        {relatedGuide.title}
      </Link>
    </p>
  );
}
