Skip to content

Commit 936855f

Browse files
authored
Merge pull request #28 from DIGOARTHUR/20-usegithubautomatedrepos-add-other-type-of-img-file-in-banner---svg
#20 Add more type of image file in banner - .svg
2 parents dda12e8 + cfd787e commit 936855f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/hooks/useGithubAutomatedRepos.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ export function useGitHubAutomatedRepos(usernameGitHub: string, keyWordDeploy: s
5858

5959
fetchData();
6060
}, [usernameGitHub, keyWordDeploy]);
61+
62+
63+
const typeImg = ['svg', 'png'];
64+
function checkImage(usernameGitHub: string, repositoryName: string): string {
65+
let checkURL = '';
66+
typeImg.map((type) => {
67+
const url = `https://raw.githubusercontent.com/${usernameGitHub}/${repositoryName}/main/src/assets/imgs/banner.${type}`;
68+
const http = new XMLHttpRequest();
69+
http.open('HEAD', url, false);
70+
http.send();
71+
72+
if (http.status === 200) {
73+
checkURL = url;
74+
}
75+
});
76+
return checkURL;
77+
}
78+
79+
6180

6281
const repository = data.map((item: IGithubRepos) => ({
6382

0 commit comments

Comments
 (0)