refactor: docubook@latest template nextjs-docker

This commit is contained in:
gitfromwildan
2026-05-30 18:52:21 +07:00
parent bf2ef37f49
commit 80eb49d968
101 changed files with 1759 additions and 4165 deletions

View File

@@ -14,42 +14,38 @@ type AnchorProps = LinkProps & {
} & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps>;
const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(
({
absolute = false,
className = "",
activeClassName = "",
disabled = false,
children,
href,
...props
}, ref) => {
(
{
absolute = false,
className = "",
activeClassName = "",
disabled = false,
children,
href,
...props
},
ref
) => {
const path = usePathname();
const hrefStr = href?.toString() || '';
const hrefStr = href?.toString() || "";
// Check if URL is external
const isExternal = /^(https?:\/\/|\/\/)/.test(hrefStr);
// Check if current path matches the link
const isActive = absolute
? hrefStr.split("/")[1] === path?.split("/")[1]
: path === hrefStr;
const isActive = absolute ? hrefStr.split("/")[1] === path?.split("/")[1] : path === hrefStr;
// Apply active class only for internal links
const linkClassName = cn(
'transition-colors hover:text-primary',
"transition-colors hover:text-primary",
className,
!isExternal && isActive && activeClassName
);
if (disabled) {
return (
<span className={cn(linkClassName, "cursor-not-allowed opacity-50")}>
{children}
</span>
);
return <span className={cn(linkClassName, "cursor-not-allowed opacity-50")}>{children}</span>;
}
if (isExternal) {
return (
<a
@@ -65,12 +61,12 @@ const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(
);
}
return (
<Link
ref={ref}
href={hrefStr}
className={linkClassName}
aria-current={isActive ? "page" : undefined}
{...props}
>
{children}