Skip to content

Commit

Permalink
Merge pull request #53 from knowankit/feat/dynamic-git-projects
Browse files Browse the repository at this point in the history
feat: add dynamic git projects
  • Loading branch information
knowankit authored Apr 9, 2022
2 parents 3c2ab12 + 74b0e5c commit 7201ded
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Portfolio demo](https://github.com/knowankit/knowankit.com/blob/develop/demo.gif)

<p align="center">
<a href="https://twitter.com/knowankit">
<img alt="Twitter: Ankit Kumar" src="https://img.shields.io/twitter/follow/knowankit.svg?style=social" target="_blank" />
Expand Down
4 changes: 2 additions & 2 deletions components/homepage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Navbar from '@/components/navbar';
import RecentBlog from '@/components/homepage/recent-blog-card';
import RecentProject from '@/components/homepage/recent-project-card';
import Footer from '@/components/footer';
import getAllGithubStars from '@/lib/get-all-github-stars';
import { getAllGithubStars } from '@/lib/get-all-github-stars';
import { AiOutlineGithub } from 'react-icons/ai';
import projects from '@/data/projects';
import router, { useRouter } from 'next/router';
import router from 'next/router';

const Profile = ({ posts }) => {
useEffect(() => {
Expand Down
17 changes: 3 additions & 14 deletions components/projects/project-card.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';

import { Box, Heading, Text, Stack, useColorModeValue } from '@chakra-ui/react';
import { AiFillGithub } from 'react-icons/ai';
import Link from 'next/link';

const ProjectCard = ({ project }) => {
if (project.fork) return <></>;

return (
<Link href={project.github}>
<Link href={project['html_url'] || ''}>
<Box
maxW={'350px'}
w={'full'}
Expand All @@ -33,18 +34,6 @@ const ProjectCard = ({ project }) => {
{project.name}
</Heading>
<Text color={'gray.500'}>{project.description}</Text>
<Box display="flex">
{project.demo && (
<Box as="a" href={`https://${project.demo}`} mr="1rem">
Preview
</Box>
)}
{project.github && (
<Box as="a" href={project.github} fontSize="1.6rem">
<AiFillGithub />
</Box>
)}
</Box>
</Stack>
</Box>
</Link>
Expand Down
14 changes: 13 additions & 1 deletion components/projects/search-project.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import ProjectCard from '@/components/projects/project-card';
import { Box, InputGroup, InputRightElement, Input } from '@chakra-ui/react';
import projects from '@/data/projects';
import { getRepos } from '@/lib/get-all-github-stars';
import { AiOutlineSearch } from 'react-icons/ai';

const SearchProject = () => {
const [filteredList, setFilteredList] = useState(projects);
const [searchText, setSearchText] = useState('');

useEffect(() => {
async function fetchMyAPI() {
const data = await getRepos();

const sortedData = data.sort((a, b) => b['stargazers_count'] - a['stargazers_count']);
setFilteredList(sortedData);
}

fetchMyAPI();
}, []);

const handleChange = (e) => {
const inputValue = e.target.value;
setSearchText(inputValue);
Expand Down
10 changes: 9 additions & 1 deletion lib/get-all-github-stars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ const getAllGithubStars = async () => {
return stars;
};

export default getAllGithubStars;
const getRepos = async () => {
const URL = 'https://api.github.com/users/knowankit/repos';
const response = await fetch(URL);
const data = await response.json();

return data;
};

export { getAllGithubStars, getRepos };
2 changes: 2 additions & 0 deletions lib/mdx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */

import fs from 'fs';
import matter from 'gray-matter';
import path from 'path';
Expand Down
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
16 changes: 3 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"paths": {
"@/src/*": ["src/*"],
Expand All @@ -29,12 +25,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

1 comment on commit 7201ded

@vercel
Copy link

@vercel vercel bot commented on 7201ded Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.