Skip to content

Commit

Permalink
Merge pull request #1169 from dpc-sdp/bugfix/R20-1989-empty-tags
Browse files Browse the repository at this point in the history
[R20-1989] make sure topic/tags have a name
  • Loading branch information
waitingallday authored May 19, 2024
2 parents 80e528c + 22f8e79 commit c1f7f33
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/nuxt-ripple/mapping/base/topic-tags/topic-tags-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ export interface TideTopicTag {
export const map = (src: TideApiResponse): TideTopicTag[] => {
const topics: TideTopicTag[] = []

if (src.field_topic) {
if (src.field_topic?.name) {
topics.push({
text: src.field_topic.name,
url: src.field_topic.path?.alias || ''
})
}

const tags = (src.field_tags || []).map((rawTag) => {
return {
text: rawTag.name,
url: rawTag.path?.alias || ''
}
})
const tags = (src.field_tags || [])
.map((rawTag: any) => {
if (!rawTag?.name) return null

return {
text: rawTag.name,
url: rawTag.path?.alias || ''
}
})
.filter(Boolean)

return [...topics, ...tags]
}
Expand Down

0 comments on commit c1f7f33

Please sign in to comment.