Skip to content

Commit a8bbcf1

Browse files
authored
Merge pull request framer#354 from framer/hubspot-blog-dates
HubSpot: fix dates and alt text in blog CMS
2 parents 34e6fc5 + d97bb3c commit a8bbcf1

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

plugins/hubspot/src/blog.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ export async function getBlogPluginContext(): Promise<BlogPluginContext> {
8888
}
8989
}
9090

91-
function getFieldDataEntryInput(field: ManagedCollectionFieldInput, value: unknown): FieldDataEntryInput | undefined {
91+
function getFieldDataEntryInput(
92+
field: ManagedCollectionFieldInput,
93+
value: unknown,
94+
post?: BlogPost
95+
): FieldDataEntryInput | undefined {
9296
switch (field.type) {
9397
case "string": {
9498
if (typeof value !== "string") return undefined
@@ -101,8 +105,8 @@ function getFieldDataEntryInput(field: ManagedCollectionFieldInput, value: unkno
101105
}
102106

103107
case "date": {
104-
if (typeof value !== "number") return undefined
105-
return { type: "date", value: new Date(value).toUTCString() }
108+
if (typeof value !== "string") return undefined
109+
return { type: "date", value }
106110
}
107111

108112
case "boolean": {
@@ -117,6 +121,15 @@ function getFieldDataEntryInput(field: ManagedCollectionFieldInput, value: unkno
117121

118122
case "image": {
119123
if (typeof value !== "string") return undefined
124+
125+
// Include alt text in featuredImage
126+
if (field.id === "featuredImage" && post) {
127+
const alt = post.featuredImageAltText
128+
if (alt) {
129+
return { type: "image", value, alt }
130+
}
131+
}
132+
120133
return { type: "image", value }
121134
}
122135

@@ -171,7 +184,7 @@ function processPost({ post, fieldsById, unsyncedItemIds, status }: ProcessPostP
171184
// Not included in field mapping, skip
172185
if (!field) continue
173186

174-
const fieldDataEntryInput = getFieldDataEntryInput(field, propertyValue)
187+
const fieldDataEntryInput = getFieldDataEntryInput(field, propertyValue, post)
175188
if (fieldDataEntryInput) {
176189
fieldData[propertyName] = fieldDataEntryInput
177190
} else {

0 commit comments

Comments
 (0)