-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
35 lines (30 loc) · 1008 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const linksSocialMedia = {
github: "rocketseat",
youtube: "rocketseat",
instagram: "rocketseat_oficial",
facebook: "rocketseat",
twitter: "rocketseat",
};
function changeSocialMediaLinks() {
for (let li of socialMediaLinks.children) {
let linkClass = li.getAttribute("class");
// Se já tiver o link-base
li.children[0].href += linksSocialMedia[linkClass];
// Outra opção, usando template string
li.children[0].href = `https://${linkClass}.com/${linksSocialMedia[linkClass]}`;
}
}
changeSocialMediaLinks();
function getGithubProfileInfo() {
const url = `https://api.github.com/users/${linksSocialMedia.github}`;
fetch(url)
.then((response) => response.json())
.then((data) => {
githubUserName.textContent = data.name;
githubUserBio.textContent = data.bio;
githubUserLink.href = data.html_url;
githubUserAvatar.src = data.avatar_url;
githubUserUsername.textContent = linksSocialMedia.github;
});
}
getGithubProfileInfo();