Skip to content

Commit

Permalink
Logic for absolute URLs in the case where we link outside of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goodroot committed Dec 13, 2024
1 parent 8184bf3 commit 5b33f82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion documentation/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ QuestDB Enterprise offers everything from open source, plus additional features
for running QuestDB at greater scale or significance.

<div className="not-prose">
<DocButton href="/enterprise/" variant="text" arrow="right">
<DocButton href="/enterprise/" absolute variant="text" arrow="right">
<>Learn more</>
</DocButton>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/components/DocButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const variantStyles = {
type ButtonProps = {
variant?: keyof typeof variantStyles
arrow?: 'left' | 'right'
absolute?: boolean
} & (
| React.ComponentPropsWithoutRef<typeof Link>
| (React.ComponentPropsWithoutRef<'button'> & { href?: undefined })
Expand All @@ -39,6 +40,7 @@ export function DocButton({
className,
children,
arrow,
absolute,
...props
}: ButtonProps) {
className = clsx(
Expand Down Expand Up @@ -79,6 +81,14 @@ export function DocButton({
)
}

if (absolute && props.href?.startsWith('/')) {
return (
<a className={className} {...props}>
{inner}
</a>
)
}

return (
<Link className={className} {...props}>
{inner}
Expand Down

0 comments on commit 5b33f82

Please sign in to comment.