2.0.7 • Published 1 year ago

@kwooshung/nextjs-arcodesign-link v2.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@kwooshung/nextjs-arcodesign-link

GitHub License GitHub Release Date - Published_At GitHub last commit GitHub code size in bytes GitHub top language GitHub pull requests GitHub issues Github Stars NPM Version Npm.js Downloads/Week Github CI/CD codecov Maintainability Gitee Repo

Why Develop It?

In Next.js projects, it's officially recommended to use the Next.js Link component for navigation. However, integrating the Arco Design Link component in Next.js can be cumbersome. This component resolves this issue by offering full compatibility with the properties of both frameworks, thereby simplifying integration for developers.

What Pain Points Does It Solve?

  • Integrating the Arco Design Link component into a Next.js project can be a hassle due to compatibility issues.
  • This component addresses these problems by offering full compatibility with the attributes of both frameworks, simplifying integration for developers.
  • It provides all the properties of the Arco Design Link component, as well as all the properties of the Next.js Link component, making it more convenient to use in both frameworks.

Why Use It?

  • Supports automatic determination of whether the domain name belongs to one's own rel='noopener noreferrer' to prevent window.opener attacks and improve security;
  • Support setting the global link whitelist through the 'LinkProvider' component, and automatically determine whether rel='noopener noreferrer' needs to be added;
  • Easy to use, simple operation, low learning curve, and high flexibility.
  • Implemented with modern ES6 features.
  • Written in TypeScript for type safety.
  • Supports on-demand import, esm modularization, naturally supports tree-shaking, so no worries about the size of the package after bundling.
  • Also provides a commonjs version in cjs format.
  • Test coverage of 100%.

Demo

Installation

npm

npm install @kwooshung/nextjs-arcodesign-link

yarn

yarn add @kwooshung/nextjs-arcodesign-link

pnpm

pnpm add @kwooshung/nextjs-arcodesign-link

Usage

import { Link } from '@kwooshung/nextjs-arcodesign-link';

const App = () => {
  return (
    <LinkProvider>
      <Link href='#' status='error'>
        Error Link
      </Link>
      <Link href='#' status='error' disabled>
        Error Link
      </Link>
      <Link href='#' status='success'>
        Success Link
      </Link>
      <Link href='#' status='success' disabled>
        Success Link
      </Link>
      <Link href='#' status='warning'>
        Warning Link
      </Link>
      <Link href='#' status='warning' disabled>
        Warning Link
      </Link>
    </LinkProvider>
  );
};

export default App;

API

LinkProvider

Link

The link component combines all the properties of the Link component of NextJs and the Link component of Arco Design.

LinkProvider Props

PropertyDescriptionTypeDefaultValue
whitelistGlobal link whitelist, automatically determines whether to add rel='noopener noreferrer'string[]'zhidi.vip', 'wozhidi.vip', 'wozhidi.com', 'google.com', 'bing.com', 'baidu.com', 'yandex.ru', 'duckduckgo.com', 'yahoo.com', 'facebook.com', 'twitter.com', 'instagram.com', 'linkedin.com', 'weibo.com', 'zhihu.com', 'mp.weixin.qq.com', 'tiktok.com', 'douyin.com', 'pinterest.com', 'reddit.com', 'snapchat.com', 'telegram.org', 'vk.com'
linkCustom link component, used to replace the default link component; for example, some internationalized components with routing functions will export dedicated LinkLink-

ArcoDesign Link Props

PropertyDescriptionTypeDefaultValueVersion
disabledWhether to disableboolean--
hoverableWhether to hide background when hoverbooleantrue2.23.0
statusThe status of Link'error' | 'success' | 'warning'--
classNameAdditional css classstring | string[]--
iconCustom Icon, Display the default icon when set to true.ReactNode | boolean--
styleAdditional styleCSSProperties--

NextJs Link Props

PropertyDescriptionTypeDefaultValue
hrefThe path or URL to navigate to. It can also be an object.string | UrlObject-
asOptional decorator for the path that will be shown in the browser URL bar. Before Next.js 9.5.3 this was used for dynamic routes, check our previous docs to see how it worked. Note: when this path differs from the one provided in href the previous href/as behavior is used as shown in the previous docs.string | UrlObject-
replaceReplace the current history state instead of adding a new url into the stack.booleanfalse
scrollWhether to override the default scroll behaviorbooleantrue
shallowUpdate the path of the current page without rerunning getStaticProps, getServerSideProps or getInitialProps.booleanfalse
passHrefForces Link to send the href property to its child.booleanfalse
prefetchThe active locale is automatically prepended. locale allows for providing a different locale. When false href has to include the locale as the default behavior is disabled.booleantrue
localeEnable legacy link behavior.string | false-
legacyBehaviorEnable legacy link behavior.booleanfalse
onMouseEnterOptional event handler for when the mouse pointer is moved onto LinkReact.MouseEventHandler-
onTouchStartOptional event handler for when Link is touchedReact.TouchEventHandler-
onClickOptional event handler for when Link is clickedReact.MouseEventHandler-
2.0.3

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago