Skip to content

Commit

Permalink
[sitecore-jss] Introduce extra types from Edge schema into models
Browse files Browse the repository at this point in the history
  • Loading branch information
art-alexeyenko committed Aug 21, 2024
1 parent 3e5d77c commit f09a6cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/sitecore-jss/src/layout/content-styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
import {
ComponentRendering,
DatasourceField,
Field,
HtmlElementRendering,
Item,
Expand Down Expand Up @@ -59,7 +60,10 @@ export const traversePlaceholder = (
});
};

export const traverseField = (field: Field | Item | Item[] | undefined, config: Config) => {
export const traverseField = (
field: Field | Item | Item[] | DatasourceField | undefined,
config: Config
) => {
if (!field || config.loadStyles) return;

if ('editable' in field && field.editable) {
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss/src/layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
ComponentParams,
EditMode,
FieldMetadata,
DatasourceField,
} from './models';

export {
Expand Down
14 changes: 12 additions & 2 deletions packages/sitecore-jss/src/layout/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ export type PlaceholdersData<TYPEDNAME extends string = string> = {
[P in TYPEDNAME]: Array<ComponentRendering | HtmlElementRendering>;
};

export interface DatasourceField {
datasource: Item;
}

/**
* Content field data passed to a component
*/
export interface ComponentFields {
[name: string]: Field | Item | Item[];
[name: string]: Field | Item | Item[] | DatasourceField;
}

/**
Expand Down Expand Up @@ -137,7 +141,7 @@ export interface FieldMetadata {
}

/**
* Content data returned from Content Service
* Content data returned from Layout Service
*/
export interface Item {
name: string;
Expand All @@ -147,6 +151,12 @@ export interface Item {
fields: {
[name: string]: Field | Item | Item[] | undefined;
};
field?: {
[name: string]: Field;
};
children?: {
results: Item[];
};
}

/**
Expand Down

0 comments on commit f09a6cd

Please sign in to comment.