Members
defaultTemplate :LinkTemplate
The default link template.
- LinkTemplate
- Source
defaultTemplateName
- Source
defaultTemplateName
- Source
speciallyCapitalisedWords
- Source
speciallyCapitalisedWords
- Source
templateNames :Array.<string>
A list of the names of the registered link templates.
- Array.<string>
- Source
util
- Source
- See
- Linfifier.utilities
utilities :Object.<string, function()>
- Object.<string, function()>
- Source
Methods
(async) fetchPageData(url) → {PageData}
Fetch the page data for a given URL.
| Name | Type | Description |
|---|---|---|
url | URL |
- Source
A validation error is thrown unless a valid URL is passed.
- Type
- ValidationError
- Type:
- PageData
(async) generateLink(url, templateNameopt) → {string}
Generate a link given a URL. By default the registered template for the URL's domain will be used, or, if none is registered, the overall default will be used (html).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url | URL | |||
templateName | templateName | <optional> | 'html' |
- Source
A validation error is thrown unless a valid URL is passed.
- Type
- ValidationError
- Type:
- string
getTemplate(templateName) → {LinkTemplate}
Get a registered link template by name.
| Name | Type | Description |
|---|---|---|
templateName | string |
- Source
A validation error is thrown unless a valid name is passed and corresponds to a registered template.
- Type
- ValidationError
- Type:
- LinkTemplate
getTemplateNameForDomain(domain) → {dataTransformer}
Get the data transformer function for a given domain.
Note that domains are searched from the subdomain up. For example, if passed the domain www.bartificer.net the function will first look for a transformer for the domain www.bartificer.net, if there's no transformer registered for that domain it will look for a transformer for the domain bartificer.net, if there's no transformer for that domain either it will return the default transformer.
| Name | Type | Description |
|---|---|---|
domain | domainName | The domain to get the data transformer for. |
- Source
A validation error is thrown unless a valid domain name is passed.
- Type
- ValidationError
- Type:
- dataTransformer
getTransformerForDomain(domain) → {dataTransformer}
Get the data transformer function for a given domain.
Note that domains are searched from the subdomain up. For example, if passed the domain www.bartificer.net the function will first look for a transformer for the domain www.bartificer.net, if there's no transformer registered for that domain it will look for a transformer for the domain bartificer.net, if there's no transformer for that domain either it will return the default transformer.
| Name | Type | Description |
|---|---|---|
domain | domainName | The domain to get the data transformer for. |
- Source
A validation error is thrown unless a valid domain name is passed.
- Type
- ValidationError
- Type:
- dataTransformer
registerDefaultTemplateMapping(domain, templateName)
Register a default template for use with a given domain. This template will override the overall default for this domain and all its subdomains.
| Name | Type | Description |
|---|---|---|
domain | domainName | The domain for which this template should be used by default. |
templateName | templateName | The name of the template to use. |
- Source
A validation error is thrown if either parameter is missing or invalid.
- Type
- ValidationError
registerTemplate(name, template)
Register a link template.
| Name | Type | Description |
|---|---|---|
name | templateName | |
template | module:@bartificer/linkify. |
- Source
A validation error is thrown unless both a valid name and template object are passed.
- Type
- ValidationError
registerTransformer(domain, transformerFn)
Register a data transformer function for a given domain.
| Name | Type | Description |
|---|---|---|
domain | domainName | The domain for which this transformer should be used. |
transformerFn | dataTransformer | The data transformer callback. |
- Source
A validation error is thrown if either parameter is missing or invalid.
- Type
- ValidationError