Extend Page Props Factory in Sitecore XM Cloud to Inject Custom Data into the Layout Service
Hello everyone! In this blog, we'll explore how to extend the page props factory plugin to add our own custom fields. We will take a realistic example to understand the concepts. XM Cloud is based on the SXA framework. In SXA, there was an option to add and manage the favicon directly from the CMS. However, this functionality is not available in XM Cloud. Instead, the favicon is typically placed in the public directory of your Next.js application to ensure public accessibility. If you want the favicon to be managed exclusively through the CMS, what approach can be taken to achieve this? So let's get started with CMS changes.First Step will be to add favIcon template with favIcon field. Second will be to add that template as base template for your main Settings item. Follow the below screenshot. Let's see the FE changes that we need to do. Create a new file called CustomContextResolver.ts under lib --> page-props-factory --> plugins Add the below code. Check...