QuickNav
Methods
- compileContentItem(contentItemData, layoutName) → {Promise}
- compileDetailPage(detailPageId, contentItem)
- getChannelAccessToken() → {String}
- getComponentInstanceData(instanceID) → {Object}
- getContentClient() → {Promise}
- getCustomPageProperty(propertyName, pageIdopt) → {String|undefined}
- getCustomSiteProperty(propertyName) → {String|undefined}
- getDefaultPageProperty(propertyName) → {String|undefined}
- getDetailPageId() → {String}
- getPageLinkData(pageId) → {SCSCompileAPI.PageLinkData}
- getPageURL(pageId) → {String}
- getSiteId() → {String}
- getSiteProperty(propertyName) → {String}
- installNodePackages(packages) → {Promise}
SCSCompileAPI
The SCSCompileAPI object namespace.
Properties:
| Name | Type | Description |
|---|---|---|
contentServer |
String | The URL to the server for content. |
navigationRoot |
String | The ID of the node that is the root of the site. |
navigationCurr |
String | The ID of the current page node. |
structureMap |
String | All of the nodes of the site hierarchy and accessed by ID. |
siteInfo |
String | All the site properties. |
siteFolder |
String | The file system location of the site's compiled pages. |
componentsFolder |
String | The file system location of the components associated with the site. |
themesFolder |
String | The file system location of the theme associated with the site. |
pageLocale |
String | The locale value for the current page being compiled, like "en" or "fr-CA". |
localeAlias |
String | The locale alias value for the current page being compiled, if configured. |
pageModel |
String | The page model for the current page being compiled. |
detailContentItem |
String | The content item associated with a detail page compilation. |
channelAccessToken |
String | The channel access token associated with the site being compiled. |
deviceInfo |
String | An object used to determine the device information for the page being compiled. When mobile pages are being compiled, this will be { isMobile: true }. |
snippetOnly |
String | Indicates if a Content Item snippet is being generated instead of a site compilation. |
- Source:
Methods
compileContentItem(contentItemData, layoutName) → {Promise}
Compile another content item, returning the HTML created by the content item's compiler.
This is used where you have one content item that references a different content item and you want to
call the referenced item's compiler instead of duplicating the code.
Note: The hydrate method on the compiled content layout is not called automatically. If it is required
then the hydrate function on the current content layout will need to handle it.
This is used where you have one content item that references a different content item and you want to
call the referenced item's compiler instead of duplicating the code.
Note: The hydrate method on the compiled content layout is not called automatically. If it is required
then the hydrate function on the current content layout will need to handle it.
Parameters:
| Name | Type | Description |
|---|---|---|
contentItemData |
Object | Data to use when the content item is compiled. |
layoutName |
String | Name of the content layout to use to compile this content item. |
- Source:
Returns:
JavaScript Promise object that is resolved to the SCSCompileAPI.CompiledContent object
- Type
- Promise
Example
// Compile the "Author" content item for a "Blog" content item
SCSCompileAPI.compileContentItem(contentItemData, 'AuthorComponent').then((result) => {
console.log(result);
});
compileDetailPage(detailPageId, contentItem)
Compile the designated content item using the specified detail page.
Parameters:
| Name | Type | Description |
|---|---|---|
detailPageId |
String | The page ID of the detail page to be used. If this is undefined, it will use the default detail page. |
contentItem |
Object | The content information for the Content Item to compile. |
- Source:
Example
SCSCompileAPI.compileDetailPage('104', contentItemData);
getChannelAccessToken() → {String}
Get the channel access token associated with the site being compiled.
This returns the same value as the channelAccessToken property.
This returns the same value as the channelAccessToken property.
- Source:
Returns:
channelAccessToken of the publishing channel for the site.
- Type
- String
Example
const channelAccessToken = SCSCompileAPI.getChannelAccessToken();
getComponentInstanceData(instanceID) → {Object}
Get the instance data associated with the referenced Component.
Parameters:
| Name | Type | Description |
|---|---|---|
instanceID |
String | of the component to fetch. |
- Source:
Returns:
metadata representing the component instance on the page including the CustomSettingsData.
- Type
- Object
Example
const componentMetadata = SCSCompileAPI.getComponentInstanceData('6cf17959-b488-4c7d-9e00-a13515ad4ca2100');
getContentClient() → {Promise}
Get the contentClient object that can be used to make OCM Content REST calls
- Source:
Returns:
JavaScript Promise object that is resolved to a Content Client object that can be used to make OCM Content REST calls.
- Type
- Promise
Example
// Get the information about the content client
SCSCompileAPI.getContentClient().then((contentClient) => {
console.log(contentClient.getInfo());
});
getCustomPageProperty(propertyName, pageIdopt) → {String|undefined}
Gets a page property value given a page ID and property name.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
propertyName |
String | Property name. | |
pageId |
String |
<optional> |
The page ID. |
- Source:
Returns:
The property value
- Type
- String | undefined
Example
const pageProperty = SCSCompileAPI.getCustomPageProperty('propertyName');
getCustomSiteProperty(propertyName) → {String|undefined}
Gets a custom site property value given a property name.
Parameters:
| Name | Type | Description |
|---|---|---|
propertyName |
String | Property name. |
- Source:
Returns:
The property value
- Type
- String | undefined
Example
const myCustomProp = SCSCompileAPI.getSiteProperty('aCustomSiteProperty');
getDefaultPageProperty(propertyName) → {String|undefined}
Gets a default page property value given a property name.
Parameters:
| Name | Type | Description |
|---|---|---|
propertyName |
String | Property name. |
- Source:
Returns:
The property value
- Type
- String | undefined
Example
const defaultPageProperty = SCSCompileAPI.getDefaultPageProperty('propertyName');
getDetailPageId() → {String}
Get the default detail page Id for the site.
This is the first page found that is marked as "detail" in the site hierarchy.
This is the first page found that is marked as "detail" in the site hierarchy.
- Source:
Returns:
detailPageId default detail page for the site.
- Type
- String
Example
const detailPageId = SCSCompileAPI.getDetailPageId();
getPageLinkData(pageId) → {SCSCompileAPI.PageLinkData}
Get the information to navigate to another page in the site.
Parameters:
| Name | Type | Description |
|---|---|---|
pageId |
String | Id of the target page. |
- Source:
Returns:
Details on how to navigate to the target page.
Example
const pageLinkData = SCSCompileAPI.getPageLinkData('104');
getPageURL(pageId) → {String}
Get the link href value to link to another page in the site from the current page being compiled.
In most cases, this will be the relative URL to the new page from the current page in the hierarchy.
Parameters:
| Name | Type | Description |
|---|---|---|
pageId |
String | Id of the target page. |
- Source:
Returns:
Relative URL to the referenced page from the current page.
- Type
- String
Example
const pageURL = SCSCompileAPI.getPageURL('104');
getSiteId() → {String}
Get the ID of the site that is being compiled.
- Source:
Returns:
siteId of the site being compiled.
- Type
- String
Example
const siteId = SCSCompileAPI.getSiteId();
getSiteProperty(propertyName) → {String}
Gets a site property value given a property name.
Parameters:
| Name | Type | Description |
|---|---|---|
propertyName |
String | Property name. |
- Source:
Returns:
The property value
- Type
- String
Examples
const siteName = SCSCompileAPI.getSiteProperty('siteName');
const siteRootPrefix = SCSCompileAPI.getSiteProperty('siteRootPrefix');
installNodePackages(packages) → {Promise}
Install one or more npm packages into the compilation environment.
Parameters:
| Name | Type | Description |
|---|---|---|
packages |
Array | String | The name of the node package to install, or an array of the names of node packages to install. |
- Source:
Returns:
JavaScript Promise object that is resolved when all the listed packages are installed
- Type
- Promise
Examples
SCSCompileAPI.installNodePackages(['mustache','handlebars']).then(result => {
console.log('node packages installed');
});
SCSCompileAPI.installNodePackages('mustache').then(result => {
console.log('node package installed');
});
Type Definitions
CompiledContent
Compiled Content Results.
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
content |
String | The generated HTML for the component, which will be inserted into the page. |
hydrate |
Boolean | true if the hydrate function within the render.js for this component should be called at runtime. |
- Source:
PageLinkData
Details on how to navigate to another page from the current page.
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
href |
String | Relative URL path to the referenced page from the current page. |
target |
String | Whether to open the page in a new tab or replace the current tab. |
hideInNavigation |
Boolean | Should the page be hidden or visible in the navigation menu. |
- Source: