forked from yousinix/portfolYOU
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
22 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
--- | ||
--- | ||
|
||
function get_tools(repo_name) { | ||
fetch(`https://api.github.com/repos/{{ site.github.owner_name }}/${repo_name}/topics`, { | ||
function get_tools(repo) { | ||
fetch(`https://api.github.com/repos/${repo}/topics`, { | ||
headers: { | ||
Accept: "application/vnd.github.mercy-preview+json" | ||
} | ||
}) | ||
.then(response => response.json()) | ||
.then(data => data.names.forEach(tool => { | ||
|
||
var toolSpan = document.createElement("span"); | ||
toolSpan.innerHTML = tool; | ||
toolSpan.classList.add("badge"); | ||
toolSpan.classList.add("badge-pill"); | ||
toolSpan.classList.add("text-primary"); | ||
toolSpan.classList.add("border"); | ||
toolSpan.classList.add("border-primary"); | ||
|
||
var parent = document.getElementById((`${repo_name}-tools`)); | ||
parent.appendChild(toolSpan); | ||
parent.appendChild(document.createTextNode(" ")); | ||
.then(data => { | ||
var name = repo.split("/")[1]; | ||
var parent = document.getElementById(`${name}-tools`); | ||
parse_tools(data.names).forEach(t => parent.appendChild(t)); | ||
}); | ||
} | ||
|
||
})) | ||
} | ||
function parse_tools(tools) { | ||
var classes = "badge badge-pill text-primary border border-primary ml-1"; | ||
var classesArr = classes.split(" "); | ||
return tools.map(tool => { | ||
var span = document.createElement("span"); | ||
span.classList.add(...classesArr); | ||
span.innerHTML = tool; | ||
return span; | ||
}); | ||
} |