-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from Maakaf/103-insert-some-real-projects
103 insert some real projects
- Loading branch information
Showing
12 changed files
with
359 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GITHUB_TOKEN=your_github_token |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { IGithubProjectsMaakafResponse } from '@/hooks/useFetchProjects'; | ||
import { NextResponse, NextRequest } from 'next/server'; | ||
|
||
const url = | ||
'https://raw.githubusercontent.com/Maakaf/maakaf-temp/main/src/assets/table_data/projects.json'; | ||
|
||
async function fetchGitHubData(githubLink: string) { | ||
const ownerRepo = githubLink.replace('https://github.com/', '').split('/'); | ||
const token = process.env.GITHUB_TOKEN; | ||
const query = ` | ||
query { | ||
repository(owner: "${ownerRepo[0]}", name: "${ownerRepo[1]}") { | ||
name | ||
openGraphImageUrl | ||
description | ||
url | ||
createdAt | ||
updatedAt | ||
stargazerCount | ||
languages(first: 5, orderBy: {field: SIZE, direction: DESC}) { | ||
edges { | ||
node { | ||
name | ||
} | ||
} | ||
} | ||
collaborators{ | ||
totalCount | ||
} | ||
contributors: mentionableUsers(first: 5) { | ||
edges { | ||
node { | ||
avatarUrl | ||
login | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await fetch('https://api.github.com/graphql', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
body: JSON.stringify({ query }), | ||
}); | ||
|
||
const data = await response.json(); | ||
return data.data.repository; // Adjust this based on the query response structure | ||
} | ||
|
||
export async function GET(_request: NextRequest) { | ||
try { | ||
const response = await fetch(url); | ||
const projects: IGithubProjectsMaakafResponse[] = await response.json(); | ||
|
||
if (!projects?.[0]?.githubLink) { | ||
throw new Error('Failed to fetch projects'); | ||
} | ||
|
||
const githubDataPromises = projects.map(project => | ||
fetchGitHubData(project.githubLink) | ||
); | ||
const githubData = await Promise.all(githubDataPromises); | ||
|
||
const res = NextResponse.json({ items: githubData }); | ||
res.headers.set('Cache-Control', 's-maxage=1800, stale-while-revalidate'); | ||
return res; | ||
} catch (error) { | ||
const res = NextResponse.json({ error }, { status: 500 }); | ||
res.headers.set('Cache-Control', 's-maxage=60, stale-while-revalidate'); | ||
return res; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Metadata } from 'next'; | ||
|
||
export const metadata: Metadata = { | ||
title: 'הפרויקטים', | ||
description: | ||
'הכירו את פרויקטי הקוד הפתוח של חברי הקהילה, ובחרו לאילו פרויקטים תרצו להצטרף', | ||
openGraph: { | ||
title: 'הפרויקטים | מעקף', | ||
description: | ||
'הכירו את פרויקטי הקוד הפתוח של חברי הקהילה, ובחרו לאילו פרויקטים תרצו להצטרף', | ||
url: 'https://maakaf-website.vercel.app/projects', | ||
siteName: 'Maakaf', | ||
type: 'website', | ||
images: [ | ||
{ | ||
url: 'https://maakaf-website.vercel.app/favicon.ico', | ||
width: 600, | ||
height: 600, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const ProjectsLayout = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<section className="self-center w-full h-[90vh] px-20 pb-6 flex flex-col justify-center gap-4"> | ||
{children} | ||
</section> | ||
); | ||
}; | ||
|
||
export default ProjectsLayout; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IRepositoriesAPIResponse } from '@/hooks/useFetchProjects'; | ||
import ProjectCard from './ProjectCard/ProjectCard'; | ||
import React from 'react'; | ||
|
||
const ProjectsDisplay = ({ | ||
projects, | ||
}: { | ||
projects: IRepositoriesAPIResponse; | ||
}) => { | ||
console.log('🚀 ~ projects:', projects); | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
{projects.items.map((project, i) => ( | ||
<ProjectCard key={project.url + i} project={project} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export const MempmizedProjectsDisplay = React.memo(ProjectsDisplay); |
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
Oops, something went wrong.