chore: fix getParentLabels for blocks

This commit is contained in:
Jessica Chowdhury
2025-02-28 15:17:34 +00:00
parent 119b698e82
commit 79767f6a22

View File

@@ -13,19 +13,17 @@ export function getParentLabels(
}
// Find the field that matches the current path segment
const field = currentFields.find((f) => f.name === segment)
const field = currentFields?.find((f) => {
if (f.name === segment || f.slug === segment) {return f}
})
if (!field) {
break
}
labels.push(field.label ?? segment)
// Loop the nested fields if they exist
if (field.fields) {
currentFields = field.fields
} else {
break
}
currentFields = field.fields ?? field.blocks ?? []
}
return labels