Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 93e745b
Author: Mahdi Khashan <58775404+mahdikhashan@users.noreply.github.com>
Date:   Fri Apr 7 16:53:40 2023 +0330

    chore: restructure project

commit f2fba4c
Author: Mahdi Khashan <58775404+mahdikhashan@users.noreply.github.com>
Date:   Sat Apr 1 15:02:15 2023 +0330

    docs: replace name
  • Loading branch information
mahdikhashan committed Apr 7, 2023
1 parent a56dff0 commit 5e80164
Show file tree
Hide file tree
Showing 49 changed files with 6,197 additions and 6,097 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"rules": {
"react/prop-types": 0,
"react/no-unescaped-entities": 0,
// for use in edge api routes
"@next/next/no-server-import-in-page": 0
}
}
2 changes: 1 addition & 1 deletion src/hooks/use-ninja.ts → hooks/use-ninja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export function useNinja() {
const randomSound = allSound[Math.floor(Math.random() * allSound.length)]

return {ninja, watah, hawa, randomSound, allSound}
}
}
3 changes: 1 addition & 2 deletions src/layouts/Default.tsx → layouts/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import type { PropsWithChildren } from 'react';
import React, { type PropsWithChildren } from 'react';

export default function RootLayout({ children }: PropsWithChildren) {
return (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
99 changes: 99 additions & 0 deletions lib/projects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
type Project = {
id: number;
name: string;
icon: string;
slug: string;
github: string;
website: string;
description: string;
skills: string[];
featured: boolean;
type: string;
};

const projects: Project[] = [
{
id: 1,
name: '99 Emails',
icon: '/logo.svg',
slug: '99-minutes-emails',
github: 'https://github.com/mahdikhashan/99-minutes-emails',
website: 'https://99-minutes-emails.vercel.app/',
description: 'A user friendly, safe and available temporary email service.',
skills: [
'react',
'typescript',
'redux-saga',
'chakra-ui',
'vite',
'vitest',
'cypress',
'storybook'
],
featured: true,
type: 'sideproject'
},
{
id: 2,
name: 'Aparat Python API',
icon: '/package.png',
slug: 'aparat-python',
github: 'https://github.com/mahdikhashan/aparat-python',
website: 'https://pypi.org/project/aparat-python/',
description: 'Aparat VOD Platform API Wrapper',
skills: ['python', 'REST-API', 'unit-test'],
featured: false,
type: 'python-package'
},
{
id: 3,
name: 'Vue 3 Click Outside',
icon: '/package.png',
slug: 'vue3-click-outside',
github: 'https://github.com/mahdikhashan/vue3-click-outside',
website: 'https://www.npmjs.com/package/@mahdikhashan/vue3-click-outside',
description:
'Directive for Vue 3 to run a method on clicking outside of the binded element',
skills: ['javascript', 'vue3', 'vue-test-utils', 'jest'],
featured: false,
type: 'npm-package'
},
{
id: 4,
name: 'Vercel CORS Proxy',
icon: '/package.png',
slug: 'vercel-express-proxy',
github: 'https://github.com/mahdikhashan/vercel-express-proxy',
website: 'https://github.com/mahdikhashan/vercel-express-proxy',
description: '🪞 Proxy server based on Express for Vercel platform',
type: 'template',
featured: false,
skills: ['javascript', 'node.js', 'express.js', 'vercel']
},
{
id: 5,
name: 'Vercel Express',
icon: '/package.png',
slug: 'vercel-express-template',
github: 'https://github.com/mahdikhashan/vercel-express-template',
website: 'https://github.com/mahdikhashan/vercel-express-template',
description: '🔥 Express Server Template for Vercel',
type: 'template',
featured: false,
skills: ['javascript', 'node.js', 'express.js', 'vercel']
},
{
id: 6,
name: 'Veemoji',
icon: '/package.png',
slug: 'veemoji',
github: 'https://github.com/mahdikhashan/veemoji',
website: 'https://veemoji.surge.sh/',
description: 'A dead simple emoji component library',
type: 'npm-package',
featured: false,
skills: ['javascript', 'vue', 'npm']
}
];

export { projects, type Project };
File renamed without changes.
2 changes: 1 addition & 1 deletion src/mocks/handlers.ts → mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rest } from 'msw';
import { Category, Post } from '@/lib/types';
import { Category, Post } from '@/types/buttercms';

import PostsResponse from './responses/posts.json';
import ProjectsResponse from './responses/projects.json';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/pages/404.tsx → pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* eslint-disable react/no-unescaped-entities */
import Head from "next/head";
import Link from "next/link";

export default function Custom404() {
return (
<>
<Head>
<title>404 | Mohi Khashan</title>
<title>404 | Mahdi Khashan</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/blog.tsx → pages/blog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link';

import { Post } from '@/lib/types';
import { Post } from '@/types/buttercms';

import { getCategories, getPostsData } from '@/lib/api';
import { InferGetStaticPropsType } from 'next';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/[slug].tsx → pages/blog/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Container from '@/ui/Container';
import { getPost, getPostsData } from '@/lib/api';
import type { Post, Views } from '@/lib/types';
import type { Post, Views } from '@/types/buttercms';
import { format } from 'date-fns';
import readingTime from 'reading-time';
import useSWR from 'swr';
Expand Down
23 changes: 8 additions & 15 deletions src/pages/index.tsx → pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import Info from '@/ui/Info';
import PostLink from '@/ui/PostLink';
import ProjectLink from '@/ui/ProjectLink';
import Container from '@/ui/Container';
import { Category, Post } from '@/lib/types';
import { Category, Post } from '@/types/buttercms';

import type { Project } from '@/lib/projects';
import { projects } from '@/lib/projects';

export default function HomePage({
posts,
Expand Down Expand Up @@ -68,7 +71,7 @@ export default function HomePage({
<Suspense fallback={null}>
<div className="flex-col space-y-2">
{projects.map((project) => (
<ProjectLink key={project.slug} {...project} />
project.featured && <ProjectLink key={project.id} {...project} />
))}
{!projects.length && <div>No Project found.</div>}
</div>
Expand All @@ -81,34 +84,24 @@ export default function HomePage({
}

export async function getServerSideProps() {
const butterToken = process.env.NEXT_PUBLIC_BUTTER_CMS_API_KEY;
const env = process.env.NODE_ENV;

if (env === 'development') {
if (process.env.NODE_ENV === 'development') {
try {

const blogPosts: Post[] = await (
await fetch('http://localhost:3000/posts')
).json();
const projects: Category[] = await (
await fetch('http://localhost:3000/projects')
).json();

return { props: { posts: blogPosts, projects } };
} catch (e) {
throw new Error('Development or Test Env: Could not get posts!');
}
}

if (butterToken) {
} else {
try {
const blogPosts: Post[] = (await getPostsData()).posts;
const projects: Category[] = await getCategories();

return { props: { posts: blogPosts, projects } };
} catch (e) {
throw new Error('Production: Could not get posts!');
}
}

return { props: { posts: [], projects: [] } };
}
35 changes: 35 additions & 0 deletions pages/projects.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { InferGetStaticPropsType } from 'next';

import Container from '@/ui/Container';
import { projects } from '@/lib/projects';
import ProjectLink from '@/ui/ProjectLink';

export default function ProjectsPage({
projects
}: InferGetStaticPropsType<typeof getStaticProps>) {
return (
<Container>
<div className="space-y-6 font-mono">
<div className="space-y-8">
<div className="mt-12 max-w-screen-md space-y-4 prose">
<h1>Projects</h1>
<h4>
Things I've made over the years while trying to learn programming.
</h4>
</div>

<div className="flex-col space-y-2">
{projects.map((project) => (
<ProjectLink key={project.id} {...project} />
))}
{!projects.length && <div>No Project found.</div>}
</div>
</div>
</div>
</Container>
);
}

export async function getStaticProps() {
return { props: { projects } };
}
Loading

2 comments on commit 5e80164

@vercel
Copy link

@vercel vercel bot commented on 5e80164 Apr 7, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 5e80164 Apr 7, 2023

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.