1.0.3 • Published 1 month ago

@constellation4sitecore/foundation-enhancers v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

Constellation Foundation Mapper

Installation

npm install @constellation4sitecore/foundation-enhancers --save

Usage

With DatasourceRendering

Similarly to withDatasourceCheck that comes OOTB to enforce a component to have a Datasource, we created a new High-Order component called withDatasourceRendering that is meant to help developers code faster by automatically checking for a Datasource if available, if not the datasource will fallback to the context item.

import { withDatasourceRendering } from '@constellation4sitecore/foundation-enhancers';

export default withDatasourceRendering()<HomepageMastheadProps>(HomepageMasthead);

This pattern takes the Component and validates if the rendering has any datasource to return fields as normal call otherwise fields will be populated with useSitecoreContext

Get Rendering Index

This helper function allows you to get index of the rendering.

const placeholders = layoutData.sitecore?.route?.placeholders;
const result = getRenderingIndex(placeholders, rendering.uid as string, 'TabbedContentRowTab');

Inputs:

  • placeholders: all layout placeholders
  • UID: Rendering UID
  • Component Name: Name of the child component.

Filter Placeholders

For example if you want to build a Tab Content Row component, you will facing an issue, if you don't filter placeholders in experience editor it will trought an error to avoid this filterPlaceholders will filter just components that name are not equal to "code".

export const getStaticProps = async (rendering: ComponentRendering) => {
  const newTabs = [] as TabViewModel[];
  const tabContentRows = filterPlaceholders(
    (rendering.placeholders as unknown as TabbedPlaceholders).TabbedContentRowTabs
  );
  for (const tabContentRow of tabContentRows) {
  }
};
1.0.4-beta.19

1 month ago

1.0.4-beta.18

2 months ago

1.0.4-beta.17

2 months ago

1.0.4-beta.13

2 months ago

1.0.4-beta.16

2 months ago

1.0.4-beta.15

2 months ago

1.0.4-beta.10

2 months ago

1.0.4-beta.12

2 months ago

1.0.4-beta.9

3 months ago

1.0.4-beta.7

3 months ago

1.0.4-beta.8

3 months ago

1.0.4-beta.2

3 months ago

1.0.4-beta.3

3 months ago

1.0.4-beta.4

3 months ago

1.0.4-beta.5

3 months ago

1.0.4-beta.6

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

6 months ago

1.0.0

8 months ago

0.1.2-beta.33

10 months ago

0.1.2-beta.31

10 months ago

0.1.2-beta.32

10 months ago

1.0.1-beta.2

8 months ago

1.0.1-beta.1

8 months ago

1.0.1-beta.0

8 months ago

1.0.1-beta.4

8 months ago

1.0.1-beta.3

8 months ago

0.1.2-beta.29

11 months ago

0.1.2-beta.28

11 months ago

0.1.2-beta.27

11 months ago

0.1.2-beta.25

11 months ago

0.1.2-beta.24

11 months ago

0.1.2-beta.23

11 months ago

0.1.2-beta.22

11 months ago

0.1.2-beta.21

11 months ago

0.1.2-beta.20

11 months ago

0.1.2-beta.19

11 months ago

0.1.1-beta.17

12 months ago

0.1.1-beta.16

12 months ago

0.1.1-beta.14

12 months ago

0.1.1-beta.13

12 months ago

0.1.1-beta.12

12 months ago

0.1.1-beta.11

12 months ago