Skip to main content
This release is 9 versions behind 1.3.0 — the latest version of @fedify/fedify. Jump to latest

Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
a month ago (1.2.0)
class Link

A Link is an indirect, qualified reference to a resource identified by a URL. The fundamental model for links is established by RFC 5988. Many of the properties defined by the Activity Vocabulary allow values that are either instances of Object or Link. When a Link is used, it establishes a qualified relation connecting the subject (the containing object) to the resource identified by the href. Properties of the Link are properties of the reference as opposed to properties of the resource.

Constructors

new
Link(
values: { id?: URL | null; href?: URL | null; rel?: string | null; rels?: (string)[]; mediaType?: string | null; name?: ; names?: ((string | LanguageString))[]; language?: LanguageTag | null; height?: number | null; width?: number | null; previews?: ()[]; },
unnamed 1?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
)

Constructs a new instance of Link with the given values.

Properties

protected
readonly
_contextLoader: DocumentLoader | undefined
protected
readonly
_documentLoader: DocumentLoader | undefined
readonly
height: number | null

On a Link, specifies a hint as to the rendering height in device-independent pixels of the linked resource.

readonly
href: URL | null

The target resource pointed to by a Link.

readonly
id: URL | null
readonly
language: LanguageTag | null

Hints as to the language used by the target resource. Value MUST be a BCP 47 Language-Tag.

readonly
mediaType: string | null

When used on a Link, identifies the MIME media type of the referenced resource.

readonly
name:

A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.

readonly
names: ((string | LanguageString))[]

A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.

readonly
previewIds: URL[]

Similar to Link.getPreviews, but returns their @ids instead of the objects themselves.

readonly
rel: string | null

A link relation associated with a Link. The value MUST conform to both the HTML5 and RFC 5988 "link relation" definitions.

In the HTML5, any string not containing the space (U+0020), tab (U+0009), LF (U+000A), FF (U+000C), CR (U+000D) or comma (U+002C) characters can be used as a valid link relation.

readonly
rels: (string)[]

A link relation associated with a Link. The value MUST conform to both the HTML5 and RFC 5988 "link relation" definitions.

In the HTML5, any string not containing the space (U+0020), tab (U+0009), LF (U+000A), FF (U+000C), CR (U+000D) or comma (U+002C) characters can be used as a valid link relation.

readonly
width: number | null

On a Link, specifies a hint as to the rendering width in device-independent pixels of the linked resource.

Methods

[Symbol.for("nodejs.util.inspect.custom")](
_depth: number,
options: unknown,
inspect: (
value: unknown,
options: unknown,
) => string
,
): string
protected
_getCustomInspectProxy(): Record<string, unknown>
clone(
values?: { id?: URL | null; href?: URL | null; rel?: string | null; rels?: (string)[]; mediaType?: string | null; name?: ; names?: ((string | LanguageString))[]; language?: LanguageTag | null; height?: number | null; width?: number | null; previews?: ()[]; },
options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
): Link

Clones this instance, optionally updating it with the given values.

getPreviews(options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; suppressError?: boolean; }): AsyncIterable<Link | Object>

Identifies an entity that provides a preview of this object.

toJsonLd(options?: { format?: "compact" | "expand"; contextLoader?: DocumentLoader; context?:
string
| Record<string, string>
| (string | Record<string, string>)[]
; }
): Promise<unknown>

Converts this object to a JSON-LD structure.

Static Properties

readonly
typeId: URL

The type URI of Link: https://www.w3.org/ns/activitystreams#Link.

Static Methods

fromJsonLd(
json: unknown,
options?: { documentLoader?: DocumentLoader; contextLoader?: DocumentLoader; },
): Promise<Link>

Converts a JSON-LD structure to an object of this type.

Add Package

deno add jsr:@fedify/fedify

Import symbol

import { Link } from "@fedify/fedify";

---- OR ----

Import directly with a jsr specifier

import { Link } from "jsr:@fedify/fedify";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { Link } from "@fedify/fedify";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { Link } from "@fedify/fedify";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { Link } from "@fedify/fedify";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { Link } from "@fedify/fedify";