The following example relies on the Result variable (contains information about the current search result).
To add the same Custom component:
-
In the HTML panel, copy and paste the following:
<div id="type"></div> -
In the JS panel, copy and paste the following:
const type = result.type; var metadata; switch (type) { case "MAP": metadata = result.map.metadata; break; case "TOPIC": metadata = result.topic.metadata; break; case "DOCUMENT": metadata = result.document.metadata; break; } var lastEdition; metadata.forEach(function (element) { const key = element.key; if (key === "ft:lastEdition") { lastEdition = element.values[0]; } }); const date = new Date(lastEdition); const now = Date.now(); const nbDays = (now - date) / (1000 * 3600 * 24); if (nbDays < 10) { document.getElementById("type").innerHTML = ` <ft-chip highlighted dense icon="STAR_PLAIN" iconvariant="fluid-topics"> New </ft-chip> `; }The
<ft-chip>element can use the same icons available in the Icon component. -
Save the component.
-
Save and publish the page.