Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix tags formatting #113

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)}.` : ''
}
Loading