mirror of
https://github.com/khairul169/code-share.git
synced 2026-10-24 11:53:58 +07:00
feat: add personal project list, add project settings, etc
This commit is contained in:
+17
-8
@@ -9,15 +9,24 @@ type LinkProps = {
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
const Link = ({ asChild, href, ...props }: LinkProps) => {
|
||||
const pageContext = usePageContext();
|
||||
const { urlPathname } = pageContext;
|
||||
const Comp = asChild ? Slot : "a";
|
||||
const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
||||
({ asChild, href, ...props }, ref) => {
|
||||
const pageContext = usePageContext();
|
||||
const { urlPathname } = pageContext;
|
||||
const Comp = asChild ? Slot : "a";
|
||||
|
||||
const isActive =
|
||||
href === "/" ? urlPathname === href : urlPathname.startsWith(href!);
|
||||
const isActive =
|
||||
href === "/" ? urlPathname === href : urlPathname.startsWith(href!);
|
||||
|
||||
return <Comp data-active={isActive || undefined} href={href} {...props} />;
|
||||
};
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
data-active={isActive || undefined}
|
||||
href={href}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
export default Link;
|
||||
|
||||
Reference in New Issue
Block a user