Skip to content

Commit

Permalink
Fixed unique ID not prepending (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajwhitley authored Nov 22, 2023
1 parent 04f6f15 commit f929421
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/shared/js/helpers/ContentfulContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ function ContentfulProvider({ children }) {
const origId = entry.sys.id;
const newId = idsMap[origId];
// Map fields, look for links and replace with new ids
let internalTitle = entry.fields.internalTitle['en-US'];
internalTitle =
internalTitle.indexOf('TEMPLATE - ') === 0
? internalTitle.replace('TEMPLATE - ', `${uniqueId} - `)
: `${uniqueId} - ${internalTitle}`;
const newitem = await environment.createEntryWithId(entry.sys.contentType.sys.id, newId, {
fields: {
...entry.fields,
internalTitle: {
'en-US': entry.fields.internalTitle['en-US'].replace('TEMPLATE - ', `${uniqueId} - `)
'en-US': internalTitle
}
},
metadata: {
Expand Down

0 comments on commit f929421

Please sign in to comment.