@@ -26,67 +26,57 @@ interface Response {
26
26
}
27
27
28
28
const sort = ( repositories : Repository [ ] ) => {
29
- const sorted = repositories . sort ( ( a : any , b : any ) => {
30
- if ( a . name . toUpperCase ( ) > b . name . toUpperCase ( ) ) return - 1
31
- if ( a . name . toUpperCase ( ) < b . name . toUpperCase ( ) ) return 1
32
- return 0 ;
33
- } )
34
- // ポートフォリオのリポジトリは先頭に表示する
35
- const index = sorted . findIndex ( repo => repo . name === "portfolio" ) ;
36
- const portfolio = sorted [ index ] ;
37
- const filtered = sorted . filter ( repo => repo . name !== "portfolio" ) ;
38
- filtered . unshift ( portfolio ) ;
39
- return filtered ;
29
+ return repositories
30
+ // const sorted = repositories.sort((a: any, b: any) => {
31
+ // if (a.name.toUpperCase() > b.name.toUpperCase()) return -1
32
+ // if (a.name.toUpperCase() < b.name.toUpperCase()) return 1
33
+ // return 0;
34
+ // })
35
+ // // ポートフォリオのリポジトリは先頭に表示する
36
+ // const index = sorted.findIndex(repo => repo.name === "portfolio");
37
+ // const portfolio = sorted[index];
38
+ // const filtered = sorted.filter(repo => repo.name !== "portfolio");
39
+ // filtered.unshift(portfolio);
40
+ // return filtered;
40
41
}
41
42
42
43
// プライベートリポジトリは、APIで取得できないため、個別で記載する
43
- const mergePrivateRepository = ( repositories : Repository [ ] ) => {
44
- const privateRepos : Repository [ ] = [
44
+ const getRepositories = ( ) => {
45
+ const repos : Repository [ ] = [
45
46
{
46
47
name : "kron" ,
47
48
description : "kintoneのレコードデータと添付ファイルを自動で毎日CSV出力するWebサービスです。" ,
48
49
// homepage: "https://kron.nw-apps.jp/lp",
49
50
skills : [ "ruby" , "rails" , "tailwindcss" , "typescript" , "jest" , "sendgrid" , "cloudrun" , ] ,
50
- thumbnail : kron_thumbnail . src ,
51
+ thumbnail : "https://raw.githubusercontent.com/nkwtnb/xlsx-creator-web/refs/heads/images/thumbnail.png" ,
51
52
isPrivate : true
52
53
}
53
54
]
54
- privateRepos . forEach ( repo => {
55
- repositories . push ( repo )
56
- } )
57
- return repositories
55
+ return repos
58
56
}
59
57
60
58
const repositoryFetcher = async ( url : string ) => {
61
- const data = await fetch ( url ) . then ( r => r . json ( ) ) ;
62
- const repositories = data . items . map ( ( item : GitHubApiResponse ) : Repository => {
63
- return {
64
- name : item . name ,
65
- description : item . description ,
66
- svn_url : item . svn_url ,
67
- homepage : item . homepage ,
68
- skills : item . topics . filter ( topic => topic !== "portfolio" ) // portfolio以外の使用スキルタグを表示
69
- }
70
- } ) ;
71
- const mergedRepositories = mergePrivateRepository ( repositories )
59
+ //
60
+ const mergedRepositories = getRepositories ( )
72
61
return mergedRepositories ;
73
62
}
74
63
const thumbnailFetcher = async ( url : string , repositories : Repository [ ] ) => {
64
+ console . log ( "repos" , repositories )
75
65
if ( ! repositories ) {
76
66
return ;
77
67
}
78
68
const thumbnails = await Promise . all ( repositories . map ( async repo => {
79
- if ( repo . isPrivate ) return repo
80
- const BRANCHES_URL = `https://api.github.com/repos/nkwtnb/${ repo . name } /branches` ;
81
- const branches = await fetch ( BRANCHES_URL ) . then ( r => r . json ( ) ) ;
82
- const hasImages = branches . some ( ( branch : any ) => branch . name === "images" ) ;
83
- if ( ! hasImages ) return repo ;
84
- const URL = `https://api.github.com/repos/nkwtnb/${ repo . name } /contents/thumbnail.png?ref=images` ;
85
- const resp = await fetch ( URL ) . then ( r => r . json ( ) ) ;
86
- repo . thumbnail = resp . download_url ;
69
+ // if (repo.isPrivate) return repo
70
+ // const BRANCHES_URL = `https://api.github.com/repos/nkwtnb/${repo.name}/branches`;
71
+ // const branches = await fetch(BRANCHES_URL).then(r => r.json());
72
+ // const hasImages = branches.some((branch: any) => branch.name === "images");
73
+ // if (!hasImages) return repo;
74
+ // const URL = `https://api.github.com/repos/nkwtnb/${repo.name}/contents/thumbnail.png?ref=images`;
75
+ // const resp = await fetch(URL).then(r => r.json());
76
+ // repo.thumbnail = resp.download_url;
87
77
return repo ;
88
78
} ) ) ;
89
-
79
+ console . log ( "thub" , thumbnails )
90
80
return thumbnails ;
91
81
}
92
82
@@ -105,6 +95,7 @@ export const useProductFetcher = (): Response => {
105
95
if ( errorOnThumbnail ) return makeResponse ( undefined , errorOnThumbnail ) ;
106
96
if ( ! thumbnails ) return makeResponse ( undefined , undefined ) ;
107
97
const sorted = sort ( thumbnails ) ;
98
+ console . log ( sorted )
108
99
return {
109
100
data : sorted ,
110
101
error : errorOnThumbnail ,
0 commit comments