|
|
@@ -1,4 +1,5 @@
|
|
|
import Link, { LinkProps } from 'next/link';
|
|
|
+import { Link as ScrollLink } from 'react-scroll';
|
|
|
|
|
|
import { useSiteUrl } from '~/stores/context';
|
|
|
|
|
|
@@ -25,9 +26,18 @@ export const NextLink = ({
|
|
|
|
|
|
const { data: siteUrl } = useSiteUrl();
|
|
|
|
|
|
+ if (href == null) {
|
|
|
+ return <a className={className}>{children}</a>;
|
|
|
+ }
|
|
|
+
|
|
|
// when href is an anchor link
|
|
|
- if (href == null || isAnchorLink(href)) {
|
|
|
- return <a href={href} className={className}>{children}</a>;
|
|
|
+ if (isAnchorLink(href)) {
|
|
|
+ const to = href.slice(1);
|
|
|
+ return (
|
|
|
+ <ScrollLink to={to} spy smooth="easeOutQuart" offset={-100} duration={800}>
|
|
|
+ <a href={href} className={className}>{children}</a>
|
|
|
+ </ScrollLink>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
if (isExternalLink(href, siteUrl)) {
|