Sort repo topic labels by name (#24123)

Close #24077
This commit is contained in:
wxiaoguang 2023-04-15 03:29:05 +08:00 committed by GitHub
parent ed81b608cb
commit 2902d1e9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View file

@ -41,6 +41,7 @@ export function initRepoTopicBar() {
viewDiv.children('.topic').remove();
if (topics.length) {
const topicArray = topics.split(',');
topicArray.sort();
for (let i = 0; i < topicArray.length; i++) {
const link = $('<a class="ui repo-topic large label topic"></a>');
link.attr('href', `${appSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`);
@ -57,12 +58,12 @@ export function initRepoTopicBar() {
topicPrompts.formatPrompt = xhr.responseJSON.message;
const {invalidTopics} = xhr.responseJSON;
const topicLables = topicDropdown.children('a.ui.label');
const topicLabels = topicDropdown.children('a.ui.label');
for (const [index, value] of topics.split(',').entries()) {
for (let i = 0; i < invalidTopics.length; i++) {
if (invalidTopics[i] === value) {
topicLables.eq(index).removeClass('green').addClass('red');
topicLabels.eq(index).removeClass('green').addClass('red');
}
}
}