Skip to content

Commit

Permalink
fix: fix tags formatting (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
EndBug authored Feb 13, 2024
1 parent 100786a commit 9d32018
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/Util/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ export default function Question({
)
}

/**
* Creates a ready-to-print list of tags, including semicolons as delimiters and a final period.
* @param tagsArr The raw array of tags
* @example contatTags(['foo baR', 'baz']) // 'Foo BaR; baz.'
*/
function concatTags(tagsArr: string[]): string {
return tagsArr
.map((tag, i) => {
const isFirstTag = i === 0
const isLastTag = i === tagsArr.length - 1
if (isFirstTag) return `${tag[0].toUpperCase()}${tag.slice(1)}; `
if (isLastTag) return `${tag}.`
return `${tag}; `
})
.join('')
const res = tagsArr.join('; ').trim()
return res ? `${res[0].toUpperCase()}${res.slice(1)}.` : ''
}

0 comments on commit 9d32018

Please sign in to comment.