Skip to content

Commit f609c74

Browse files
committed
リポジトリ情報をハードコーディングする
1 parent f00e66a commit f609c74

File tree

1 file changed

+29
-38
lines changed

1 file changed

+29
-38
lines changed

src/hooks/useProductFetcher.ts

+29-38
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,57 @@ interface Response {
2626
}
2727

2828
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;
4041
}
4142

4243
// プライベートリポジトリは、APIで取得できないため、個別で記載する
43-
const mergePrivateRepository = (repositories: Repository[]) => {
44-
const privateRepos: Repository[] = [
44+
const getRepositories = () => {
45+
const repos: Repository[] = [
4546
{
4647
name: "kron",
4748
description: "kintoneのレコードデータと添付ファイルを自動で毎日CSV出力するWebサービスです。",
4849
// homepage: "https://kron.nw-apps.jp/lp",
4950
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",
5152
isPrivate: true
5253
}
5354
]
54-
privateRepos.forEach(repo => {
55-
repositories.push(repo)
56-
})
57-
return repositories
55+
return repos
5856
}
5957

6058
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()
7261
return mergedRepositories;
7362
}
7463
const thumbnailFetcher = async (url: string, repositories: Repository[]) => {
64+
console.log("repos", repositories)
7565
if (!repositories) {
7666
return;
7767
}
7868
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;
8777
return repo;
8878
}));
89-
79+
console.log("thub", thumbnails)
9080
return thumbnails;
9181
}
9282

@@ -105,6 +95,7 @@ export const useProductFetcher = (): Response => {
10595
if (errorOnThumbnail) return makeResponse(undefined, errorOnThumbnail);
10696
if (!thumbnails) return makeResponse(undefined, undefined);
10797
const sorted = sort(thumbnails);
98+
console.log(sorted)
10899
return {
109100
data: sorted,
110101
error: errorOnThumbnail,

0 commit comments

Comments
 (0)