{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heading",
  "title": "Heading",
  "description": "Heading with an anchor link and a button that copies the link to the section.",
  "dependencies": [
    "cn",
    "@fuma-translate/react@^1.0.2",
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "@docscn/docs-utils"
  ],
  "files": [
    {
      "path": "registry/base/docs/components/heading.tsx",
      "content": "// Adapted from Fumadocs UI (https://github.com/fuma-nama/fumadocs)\n// Copyright (c) 2023 Fuma, MIT License\n\"use client\";\n\nimport { useTranslations } from \"@fuma-translate/react\";\nimport { cn } from \"cn\";\nimport { CopyCheckIcon, LinkIcon } from \"lucide-react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { useCopyButton } from \"../utils/use-copy-button\";\n\ntype Types = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\ntype HeadingProps<T extends Types> = Omit<ComponentPropsWithoutRef<T>, \"as\"> & {\n  as?: T;\n};\n\nexport function Heading<T extends Types = \"h1\">({\n  as,\n  ...props\n}: HeadingProps<T>) {\n  const As = as ?? \"h1\";\n  const t = useTranslations({ note: \"heading anchor\" });\n  const [isChecked, onCopy] = useCopyButton(() => {\n    if (!props.id) return;\n\n    const url = new URL(window.location.href);\n    url.hash = props.id;\n    return navigator.clipboard.writeText(url.href);\n  });\n\n  if (!props.id) return <As {...props} />;\n\n  return (\n    <As\n      {...props}\n      className={cn(\n        \"group/heading flex scroll-m-28 flex-row items-center gap-1\",\n        props.className,\n      )}\n    >\n      <a data-card=\"\" href={`#${props.id}`}>\n        {props.children}\n      </a>\n      <Button\n        variant=\"ghost\"\n        size=\"icon-xs\"\n        aria-live=\"polite\"\n        className=\"not-docs-typeset shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/heading:opacity-100 focus-visible:opacity-100\"\n        onClick={onCopy}\n      >\n        {isChecked ? <CopyCheckIcon /> : <LinkIcon />}\n        <span className=\"sr-only\">\n          {isChecked\n            ? t(\"Copied Anchor Link\", { note: \"aria-label\" })\n            : t(\"Copy Anchor Link\", { note: \"aria-label\" })}\n        </span>\n      </Button>\n    </As>\n  );\n}\n",
      "type": "registry:component",
      "target": "@components/docs/components/heading.tsx"
    }
  ],
  "type": "registry:component"
}