Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.6 kB ยท 56 lines
TSX
at incident-api
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657"use client";
import { cn } from "@openstatus/ui/lib/utils";import { type VariantProps, cva } from "class-variance-authority";import NextLink from "next/link";
import { useEmbed } from "../../hooks/use-embed";
export const linkVariants = cva( "focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]", { variants: { variant: { default: "text-foreground font-medium", container: "focus-visible:border-ring", unstyled: "", }, }, defaultVariants: { variant: "default", }, },);
export function Link({ children, className, variant, target, rel, ...props}: React.ComponentProps<typeof NextLink> & VariantProps<typeof linkVariants>) { const { mode } = useEmbed(); // NOTE: treat any non-internal href as external so we don't hijack protocol // links (mailto/tel/sms), absolute URLs, or protocol-relative URLs with // embed-mode target="_blank" overrides. const href = typeof props.href === "string" ? props.href : null; const isExternal = href !== null && (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//")); const isAnchor = href?.startsWith("#"); const shouldOpenNewTab = mode && !isExternal && !isAnchor; const embedTarget = shouldOpenNewTab ? "_blank" : target; const embedRel = shouldOpenNewTab ? (rel ?? "noopener noreferrer") : rel;
return ( <NextLink className={cn(linkVariants({ variant, className }))} target={embedTarget} rel={embedRel} {...props} > {children} </NextLink> );}