Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Fix Vercel build failures #3272

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 23 additions & 26 deletions docs/docs.trychroma.com/components/markdoc/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ interface HeadingProps {
className?: string;
}

export function Heading({ id = '', level = 1, children, className }: HeadingProps): JSX.Element {
export function Heading({ id = '', level = 1, children, className }: HeadingProps) {
const router = useRouter();
const Component = `h${level}` as keyof JSX.IntrinsicElements; // This type assertion helps to ensure that Component is a valid JSX element tag
const Component = `h${level}`;

const isDocs = router.pathname.startsWith('/docs');

Expand All @@ -34,30 +34,27 @@ export function Heading({ id = '', level = 1, children, className }: HeadingProp
className = 'text-sm mb-4 mt-4 font-semibold';
}


const link = (
<Component className={['heading', className].filter(Boolean).join(' ')}>
<div id={id} />
{children}
<a
onClick={(e) => {
e.preventDefault();
navigator.clipboard.writeText(`${window.location.origin}${router.pathname}#${id}`);
// replacestate with the current url
window.history.replaceState(null, '', `${window.location.origin}${router.pathname}#${id}`);
}}
className="text-gray-500 hover:text-gray-700 ml-2 cursor-pointer href-anchor"
>
#
</a>
</Component>
const link = React.createElement(
Component,
{ className: ['heading', className].filter(Boolean).join(' ') },
React.createElement('div', { id }),
children,
React.createElement(
'a',
{
onClick: (e) => {
e.preventDefault();
navigator.clipboard.writeText(`${window.location.origin}${router.pathname}#${id}`);
// Replace state with the current URL
window.history.replaceState(null, '', `${window.location.origin}${router.pathname}#${id}`);
},
className: 'text-gray-500 hover:text-gray-700 ml-2 cursor-pointer href-anchor',
},
'#'
)
);

return isDocs && level !== 1 ? (
<a href={`#${id}`}>
{link}
</a>
) : (
link
);
return isDocs && level !== 1
? React.createElement('a', { href: `#${id}` }, link)
: link;
}
Loading