Skip to content

Commit 7fe09c9

Browse files
authored
Merge pull request #97 from contentstack/development
addTags changes for variants
2 parents 9548804 + 731202f commit 7fe09c9

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33

4+
## [1.3.12](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.12) (2024-09-30)
5+
- Fix: addTags methods changes for Variants
6+
47
## [1.3.11](https://github.com/contentstack/contentstack-utils-javascript/tree/v1.3.11) (2024-08-21)
58
- Fix: Reference to HTML fixed to support assets that are referenced
69

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/utils",
3-
"version": "1.3.11",
3+
"version": "1.3.12",
44
"description": "Contentstack utilities for Javascript",
55
"main": "dist/index.es.js",
66
"types": "dist/types/index.d.ts",

src/entry-editable.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { EntryModel } from "."
22

33
export function addTags(entry: EntryModel, contentTypeUid: string, tagsAsObject: boolean, locale: string = 'en-us') : void {
44
if (entry) {
5-
const appliedVariants = entry._applied_variants || null;
6-
entry.$ = getTag(entry, `${contentTypeUid}.${entry.uid}.${locale}`, tagsAsObject, locale, {_applied_variants: appliedVariants, shouldApplyVariant: !!appliedVariants, metaKey: ''}) }
7-
}
5+
const appliedVariants = entry._applied_variants || entry?.system?.applied_variants || null;
6+
entry.$ = getTag(entry, `${contentTypeUid}.${entry.uid}.${locale}`, tagsAsObject, locale, {_applied_variants: appliedVariants, shouldApplyVariant: !!appliedVariants, metaKey: ''}) }
7+
}
88

99
function getTag(content: object, prefix: string, tagsAsObject: boolean, locale: string, appliedVariants: {_applied_variants:{[key: string]: any}, shouldApplyVariant: boolean, metaKey: string}): object {
1010
const tags: any = {}
@@ -48,7 +48,7 @@ import { EntryModel } from "."
4848
* }]
4949
* }
5050
*/
51-
const newAppliedVariants = obj._applied_variants || _applied_variants;
51+
const newAppliedVariants = obj._applied_variants || obj?.system?.applied_variants || _applied_variants;
5252
const newShouldApplyVariant = !!newAppliedVariants
5353
value[index].$ = getTag(obj, `${obj._content_type_uid}.${obj.uid}.${obj.locale || locale}`, tagsAsObject, locale, {_applied_variants:newAppliedVariants, shouldApplyVariant:newShouldApplyVariant, metaKey: ""})
5454
}else if (typeof obj === "object") {

0 commit comments

Comments
 (0)