Configure the Assembler to add canonical link support to the root content item.
The canonical link configuration in
the Discover Electronics reference application is located in the Assembler
context file,
WEB-INF\assembler-context.xml
. Configuration is
handled by the
canonicalLinkBuilder
which constructs links for
navigation state and record state URLs that include the canonical link element.
The following properties can be set on the
canonicalLinkBuilder
:
Property |
Description |
---|---|
|
Allows the retrieval of services without
explicit injection. In this case, it is used to reference the framework for
retrieving the
|
|
The ID of the
|
|
The ID of the
|
|
The ID of the
|
|
The list of URL parameters that are included in the canonical link. |
The configuration for the
canonicalLinkBuilder
specifies an
objectLocator
to use when creating canonical links:
<bean id="assemblerFactory" class="com.endeca.infront.assembler.spring.SpringAssemblerFactory"> ... <constructor-arg> <list> ... <bean class="com.endeca.infront.navigation.url.event.CanonicalLinkBuilder"> <property name="objectLocator" ref="springUtility"/> <property name="recordStateId" value="recordState"/> <property name="navigationStateId" value="navigationState"/> <property name="siteStateId" value="siteState"/> <property name="includedParameters"> <list> <value>R</value> <value>A</value> <value>N</value> <value>Ntt</value> </list> </property> </bean> </list> </constructor-arg> </bean>
The Assembler API returns navigation state, record state, and site state content items as output from the CanonicalLinkBuilder. The following examples are JSON representations of the output.
NavigationState
{ name: "Static Page Slot", ..., canonicalLink: { @class: "com.endeca.infront.cartridge.model.NavigationAction", navigationState: "/Canon/cameras/_/N-1z141xuZ1z141yaZ25y6Zej4?format=json", contentPath: "/browse", siteRootPath: "/pages", label: "" } }
RecordState
{ name: "Static Page Slot", ..., canonicalLink: { @class: "com.endeca.infront.cartridge.model.RecordAction", recordState: "/_/A-1318562?format=json", contentPath: "/detail", siteRootPath: "/pages", label: "" } }
SiteState
canonicalLink:{ @class":"com.endeca.infront.cartridge.model.NavigationAction", navigationState:"\/cameras\/_\/N-25y6", contentPath:"\/browse", siteRootPath:"\/pages", siteState":{"@class":"com.endeca.infront.site.model.SiteState", contentPath":"\/browse\/cameras\/_\/N-25y6", siteId:"\/DiscoverElectronics", properties:{} } label:""} } }
For each of the content items, a JSP file can render output as in this example:
<link rel="canonical" href="<c:url value='${util:getUrlForAction(rootComponent.canonicalLink)}'/>"/>