Constructor
new PageData(url)
- Source:
- See:
-
- dataTransformer for details of how instances of this class are used in the link generation process.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | The page's full URL. |
Members
(readonly) domain :string
- Description:
The domain-part of the URL.
- Source:
The domain-part of the URL.
Type:
- string
extraFields :Object.<string, string>
- Description:
The extra fields extracted from the page by a 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 a 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>
(readonly) h1s
- Description:
An alias for
.topLevelHeadings.
- Source:
- See:
An alias for .topLevelHeadings.
(readonly) h2s
- Description:
An alias for
.secondaryHeadings.
- Source:
- See:
An alias for .secondaryHeadings.
(readonly) headings :Object
- Description:
The page's primary and secondary headings.
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
h1 |
Array.<string> | The page's top-level headings ( |
h2 |
Array.<string> | The page's secondary headings ( |
The page's primary and secondary headings.
Type:
- Object
(readonly) mainHeading :string
- Description:
The text from the most important heading on the page. If the page has
h1tags, the first one will be used, if not, the firsth2tag will be used, and if there's none of those either, an empty string will be returned.
- Source:
The text from the most important heading on the page. If the page
has h1 tags, the first one will be used, if not, the first h2 tag
will be used, and if there's none of those either, an empty string will
be returned.
Type:
- string
metadata :pageMetadataObject
- Description:
The page's metadata from the page's HTML header.
When getting this property a shallow clone of the internal metadata fields object is returned.
When setting this property a comma-separated string can be passed for the keywords. All values passed are coerced to strings with
String()before being written to the internal data structure.Note that reading this property produces a shallow clone of the internal metadata fields object, and that the values set for metadata fields are coerced to strings with
String(value).
- Source:
The page's metadata from the page's HTML header.
When getting this property a shallow clone of the internal metadata fields object is returned.
When setting this property a comma-separated string can be passed for the keywords. All values passed are coerced to strings with String() before being written to the internal data structure.
Note that reading this property produces a shallow clone of the internal metadata fields object, and that the values set for metadata fields are coerced to strings with String(value).
Type:
(readonly) path :string
- Description:
The path-part of the URL.
- Source:
The path-part of the URL.
Type:
- string
(readonly) secondaryHeadings :Array.<string>
- Description:
The page's secondary headings (
h2tags).
- Source:
The page's secondary headings (h2 tags).
Type:
- Array.<string>
title :string
- Description:
The page's title. Values are coerced to strings with
String(title).
- Source:
The page's title. Values are coerced to strings with String(title).
Type:
- string
(readonly) topLevelHeadings :Array.<string>
- Description:
The page's top-level headings (
h1tags).
- Source:
The page's top-level headings (h1 tags).
Type:
- Array.<string>
(readonly) uri :module:urijs
- Source:
Type:
url :string
- Source:
Type:
- string
(static, readonly) emptyPageMetadataObject :pageMetadataObject
- Description:
A new empty page metadata object.
- Source:
A new empty page metadata object.
Type:
Methods
addExtraField(fieldName, value) → {module:page-data.PageData}
- Description:
Add an extra field to the page 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.
addSecondaryHeading(h2Text) → {module:page-data.PageData}
- Description:
Add a seconary heading.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
h2Text |
string |
Returns:
A reference to self to facilitate function chaning.
addTopLevelHeading(h1Text) → {module:page-data.PageData}
- Description:
Add a top-level heading.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
h1Text |
string |
Returns:
A reference to self to facilitate function chaning.
asPlainObject() → {plainPageInformationObject}
- Description:
Get the page data as a plain object.
- Source:
Returns:
h1()
- Description:
A shortcut for
.addTopLevelHeading().
- Source:
- See:
h2()
- Description:
A shortcut for
.addSecondaryHeading().
- Source:
- See: