Posts

Showing posts from October, 2024

How to Create a Component in Next.js for XM Cloud

Image
Let’s create a component in the Next.js app.  If you want to know how that component is created in XM Cloud, please refer to my previous blog for more information. https://sitecoresathiya.blogspot.com/2024/10/how-to-create-component-in-nextjs-for-xmc.html I have pulled down the startup branch to my local environment. https://github.com/sitecorelabs/xmcloud-foundation-head Refer to the README file to learn how to run the Next.js app locally.  Navigate to the headapps/nextjs-starter folder and execute the following command to scaffold a new component:  jss scaffold "TextCard". Let's check if the component is rendered correctly. Run the command below to start your Next.js app locally in connected mode. npm run start:connected After that, your app will run on http://localhost:3000/ with the default port if the port is not in use.   Yes, it shows what I had in my TextCard.tsx file. How can we display the content from XMC? To map the component fields into my TextCardFields...

How to Create a Custom Component in XM Cloud.

Image
The best practice for creating a component module is to navigate to Settings -> Project -> [Site Name].  This allows us to use the component across different sites as well.  To create the module, right-click on the project, select "Insert," and then click on "Headless Module." A popup modal will appear.   Specify the module name as the component name. Choose the desired path for grouping the components. The best way to organize them is to select your site name folder under the project. Create a rendering. Instead of creating a rendering, it’s best to clone a rendering and then update it accordingly. For example, clone a Promo rendering and rename it to Text Card. /sitecore/layout/Renderings/Feature/JSS Experience Accelerator/Page Content/Promo To clone the rendering, right-click on the promo, select "Scripts," and then choose "Clone Rendering."   Update the rendering name and select the path to your component folder that was created during ...