Improve getTags()

This commit is contained in:
Yang Luo
2023-04-09 14:47:08 +08:00
parent b7d78d1e27
commit 30ea3a1335
3 changed files with 20 additions and 10 deletions

View File

@ -1070,18 +1070,28 @@ export function getTagColor(s) {
return "processing";
}
export function getTags(tags) {
export function getTags(tags, urlPrefix = null) {
const res = [];
if (!tags) {
return res;
}
tags.forEach((tag, i) => {
res.push(
<Tag color={getTagColor(tag)}>
{tag}
</Tag>
);
if (urlPrefix === null) {
res.push(
<Tag color={getTagColor(tag)}>
{tag}
</Tag>
);
} else {
res.push(
<Link to={`/${urlPrefix}/${tag}`}>
<Tag color={getTagColor(tag)}>
{tag}
</Tag>
</Link>
);
}
});
return res;
}