@constellation4sitecore/labels
TypeScript icon, indicating that this package has built-in type declarations

22.2.1 • Public • Published

Constellation Labels

This module aims to streamline the management of translatable text. While SXA offers the dictionary concept, organizing items across different locations in Sitecore can prove challenging to maintain. Hence, the Labels module introduces a dedicated template per component, allowing you to consolidate all your labels in one central location for easier management.

Installation

npm install @constellation4sitecore/labels --save

Setup Serialization

In your project add in sitecore.json

  "modules": [
    ....
    "npm:@constellation4sitecore/labels"
  ],

Then you can push the items by

dotnet sitecore ser push

To install the SXA Module on your site, follow these steps:

  • Right-click on your site.
  • Navigate to "Scripts."
  • Choose "Add Site Module."
  • Select the 'Labels' option.
  • Proceed by clicking on the "Install" button.

This process will integrate the Labels module into your site, enhancing its functionality with streamlined label management.

Usage

  1. Create a Label item in sitecore
  2. Copy the created Item ID
  3. In your project create a folder for labels
import { Field, ImageField } from '@sitecore-jss/sitecore-jss-nextjs';

export type MyLabels = {
  Logo: ImageField;
  PrimaryNavigation: Field<string>;
  copyright: Field<string>;
  socialIntroText: Field<string>;
  cookieSettings: Field<string>;
};
  1. In staticProps you can call getLabelsForView to fetch labels
import { LabelService } from '@constellation4sitecore/labels';

export const getStaticProps: GetStaticComponentProps = async (
  _: ComponentRendering,
  layoutData: LayoutServiceData
) => {
  const labels = await new LabelService(layoutData).getLabelsForView<MyLabels>(
    TEMPLATES.MYLABEL_TEMPLATE_ID
  );
  return { labels: labels };
};

Readme

Keywords

none

Package Sidebar

Install

npm i @constellation4sitecore/labels

Weekly Downloads

149

Version

22.2.1

License

MIT

Unpacked Size

29.3 kB

Total Files

21

Last publish

Collaborators

  • robertoarmas
  • sgtsitecore