Constructor
new LinkData(url, textopt, descriptionopt, extraFieldsopt)
- Source:
- See:
-
- dataTransformer for details of how instances of this class are created.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url |
string | The link's URL. |
||
text |
string |
<optional> |
The link's text, defaults to the URL. The value passed is coerced to a string with |
|
description |
string |
<optional> |
A description for the link, defaults to the link text. The value passed is coerced to a string with |
|
extraFields |
Object.<string, string> |
<optional> |
{}
|
An optional set of extra fields to be made available for use in templates under the |
Throws:
-
-
A TypeError is thrown if an invalid URL is passed.
- Type
- TypeError
-
-
-
A TypeError is thrown if the extraFields parameter is not an object.
- Type
- TypeError
-
Members
description :string
- Description:
The link description.
- Source:
The link description.
Type:
- string
extraFields :Object.<string, string>
- Description:
The extra fields extracted from the page by an extra field extractor function, indexed by field name. If no field extractor was used, this will be an empty object.
Note that reading this property produces a shallow clone of the internal extra fields object, and that the values set for extra fields are coerced to strings with
String(value).
- Source:
- Default Value:
- {}
The extra fields extracted from the page by an extra field extractor function, indexed by field name. If no field extractor was used, this will be an empty object.
Note that reading this property produces a shallow clone of the internal extra fields object, and that the values set for extra fields are coerced to strings with String(value).
Type:
- Object.<string, string>
text :string
- Description:
The link text.
- Source:
The link text.
Type:
- string
(readonly) uri :module:urijs
- Description:
The URL the link points to as a URI.js object representing the URL.
- Source:
The URL the link points to as a URI.js object representing the URL.
Type:
url :string
- Description:
The URL the link points to as a string.
- Source:
The URL the link points to as a string.
Type:
- string
(static) standardFieldNames :Array.<string>
- Description:
The standard fields names that can be used within template strings to access the link data.
- Source:
The standard fields names that can be used within template strings to access the link data.
Type:
- Array.<string>
Methods
addExtraField(fieldName, value) → {module:page-data.PageData}
- Description:
Add an extra field to the link data object.
Note that values are coerced to strings with
String(value).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fieldName |
string | The name of the field to add. |
value |
string | The value of the field to add. This will be coerced to a string with |
Returns:
A reference to self to facilitate function chaning.
asPlainObject() → {plainLinkInformationObject}
- Description:
The link data as a plain object for use in Mustache templates and the like.
- Source:
Returns:
A plain object containing the link data.