Skip to content

Commit

Permalink
refactor(lib/tags): use flatMap on getRawTagListFromPosts
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Feb 13, 2024
1 parent b2ae59d commit 128c561
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/lib/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import { removeRepeatedValuesFromArray } from '~/lib/remove-repeated-values-from
import { getFrequencyOfValue } from '~/lib/get-frequency-of-value'

const getRawTagListFromPosts = (): string[] => {
const listOfTagList = allPosts
const tagList = allPosts
.filter(post => !post.test)
.map(post => {
.flatMap(post => {
return post.tags.split(',')
})
.map(tag => tag.trim())

let completeRawTagList: string[] = []

listOfTagList.forEach(tagList => {
tagList.forEach(tag => completeRawTagList.push(tag.trim()))
})

return completeRawTagList
return tagList
}

export const getUniqueTagListFromPosts = () =>
Expand Down

0 comments on commit 128c561

Please sign in to comment.