Link
An anchor element that derives its href from a directory, file, module export,
or from the RootProvider config.
import { Link, JavaScriptFile } from 'renoun' const file = new JavaScriptFile({ path: '../../packages/renoun/src/components/Link/Link.tsx', }) export async function ViewSource() { return <Link source={file}>View Source</Link> }
The Link component is an anchor element that derives its href from a directory, file, or module export, or from the RootProvider config.
It supports the following variants:
Variants
-
source(default),edit,history,raw,blame,editor -
repository,owner,branch,issue
Examples
Git Repository
View Sourceimport { Link } from 'renoun' export function GitRepository() { return ( <Link variant="repository" css={{ display: 'flex', width: '1.5rem', height: '1.5rem' }} /> ) }
Git Repository Custom
View Sourceimport { Link, Logo } from 'renoun' export function GitRepositoryCustom() { return ( <Link variant="repository" css={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }} > <Logo variant="gitHost" width="1em" height="1em" /> <span>View Repository</span> </Link> ) }
Custom Element
View Sourceimport { Link, JavaScriptFile } from 'renoun' const file = new JavaScriptFile({ path: '../../packages/renoun/src/components/Link/Link.tsx', }) export async function CustomElement() { return ( <Link source={file} variant="edit"> {({ href }) => <a href={href}>Edit Source</a>} </Link> ) }
Config Links
View Sourceimport { Link } from 'renoun' export function ConfigLinks() { return ( <ul> <li> <Link variant="repository">Repository</Link> </li> <li> <Link variant="owner">Owner</Link> </li> <li> <Link variant="branch" options={{ ref: 'release' }}> Branch </Link> </li> <li> <Link variant="issue">New Issue</Link> </li> <li> <Link variant="release"> {({ href, label }) => <a href={href}>{label}</a>} </Link> </li> </ul> ) }
API Reference
Type
"source" | "edit" | "history" | "raw" | "blame" | "editor" | "release" | "repository" | "owner" | "branch" | "issue"Properties
| Property | Type | Modifiers |
|---|---|---|
| rawTagName? | string | — |
Original tag name from the provider (e.g. GitHub | ||
| rawName? | string | — |
Original release name/title from the provider. | ||
| tag? | string | — |
Primary tag identifier, normalized from the underlying release. | ||
| name? | string | — |
Package or display name, normalized from the underlying release. | ||
| label | string | — |
Normalized label suitable for display. | ||
Methods
| Method | Signature | Modifiers |
|---|---|---|
| toString | () => string | — |
String representation when rendered in a string context. Returnsstring | ||
Properties
| Property | Type | Modifiers |
|---|---|---|
| href | string | — |
The URL of the release. | ||
| tag? | string | — |
The tag of the release. | ||
| name? | string | — |
The name of the release. | ||
| label | `${string}@${string}` | — |
The tag and name of the release. | ||
| publishedAt? | string | — |
ISO timestamp for when the release was published, if provided by the host. | ||
| isPrerelease | boolean | — |
Indicates whether the release is marked as a prerelease. | ||
| isDraft | boolean | — |
Indicates whether the release is marked as a draft. | ||
Variant extends LinkVariant
| Property | Type | |
|---|---|---|
| css? | CSSObject | |
| source? | Source | |
| variant? | Variant | |
| packageName? | string | |
| release? | string | |
| refresh? | boolean | |
| asset? | true | string | RegExp | |
| archiveSource? | "zip" | "tar" | |
| compare? | string | |
| repository? | Repository | RepositoryConfig | string | |
| children? | React.ReactNode | (context: LinkContextFor<Variant>) => React.ReactNode | |
Variant extends LinkVariant
| Property | Type | |
|---|---|---|
| css? | CSSObject | |
| source | Source | |
| variant? | Variant | |
| options? | VariantOptions<Source, Variant> | |
| children? | React.ReactNode | (context: LinkContextFor<Variant>) => React.ReactNode | |
Variant does not extend LinkVariant and Variant extends ConfigVariants
| Property | Type | |
|---|---|---|
| css? | CSSObject | |
| children? | React.ReactNode | (context: LinkContextFor<Variant>) => React.ReactNode | |
An anchor element that derives its href from a directory, file, module export,
or from the RootProvider config.
Properties
LinkProps<Source, Variant>Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Source | — | — |
Variant | LinkVariant | "source" |
Returns
Promise<string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined>Modifiers
async