import NextLink from 'next/link';
import { FC, ReactNode } from 'react';
import styles from './link.module.scss';

export type LinkProps = {
  /**
   * The link body.
   */
  children: ReactNode;
  /**
   * Set additional classnames to the link.
   */
  className?: string;
  /**
   * True if it is a download link. Default: false.
   */
  download?: boolean;
  /**
   * True if it is an external link. Default: false.
   */
  external?: boolean;
  /**
   * The link target.
   */
  href: string;
  /**
   * The link target code language.
   */
  lang?: string;
};

/**
 * Link Component
 *
 * Render a link.
 */
const Link: FC<LinkProps> = ({
  children,
  className = '',
  download = false,
  external = false,
  href,
  lang,
}) => {
  const downloadClass = download ? styles['link--download'] : '';

  return external ? (
    <a
      href={href}
      hrefLang={lang}
      className={`${styles.link} ${styles['link--external']} ${downloadClass} ${className}`}
    >
      {children}
    </a>
  ) : (
    <NextLink href={href}>
      <a
        hrefLang={lang}
        className={`${styles.link} ${downloadClass} ${className}`}
      >
        {children}
      </a>
    </NextLink>
  );
};

export default Link;
class='sub right'>Armand Philippot</td></tr></table>
<table class='tabs'><tr><td>
<a href='/www.armandphilippot.com/?h=v1.0.0'>summary</a><a href='/www.armandphilippot.com/refs/?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>refs</a><a href='/www.armandphilippot.com/log/public/prism/prism-objectivec.js?h=v1.0.0'>log</a><a class='active' href='/www.armandphilippot.com/tree/public/prism/prism-objectivec.js?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>tree</a><a href='/www.armandphilippot.com/commit/public/prism/prism-objectivec.js?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>commit</a><a href='/www.armandphilippot.com/diff/public/prism/prism-objectivec.js?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>diff</a><a href='/www.armandphilippot.com/stats/public/prism/prism-objectivec.js?h=v1.0.0'>stats</a></td><td class='form'><form class='right' method='get' action='/www.armandphilippot.com/log/public/prism/prism-objectivec.js'>
<input type='hidden' name='h' value='v1.0.0'/><input type='hidden' name='id' value='9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/www.armandphilippot.com/tree/?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>root</a>/<a href='/www.armandphilippot.com/tree/public?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>public</a>/<a href='/www.armandphilippot.com/tree/public/prism?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>prism</a>/<a href='/www.armandphilippot.com/tree/public/prism/prism-objectivec.js?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>prism-objectivec.js</a></div><div class='content'>blob: 6eecbd0fdd33883c5ce4bcb41fd8c89d7c5e681a (<a href='/www.armandphilippot.com/plain/public/prism/prism-objectivec.js?h=v1.0.0&amp;id=9b31e81c8d45eaf0dc6971655dc08b0d0a1cbe56'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
</pre></td>
<td class='lines'><pre><code>