Skip to content

Commit 5c0421f

Browse files
committed
add typescript interfaces to prevent bug
1 parent 1dbfa76 commit 5c0421f

File tree

13 files changed

+61
-53
lines changed

13 files changed

+61
-53
lines changed

components/About.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AboutContent extends Component {
3131
education: this.education,
3232
skills: this.skills,
3333
}}
34-
msg="Welcome to about page - Type 'help' to list all supported commands"
34+
msg="Hi! Welcome to about page - Type 'help' to list all supported commands"
3535
closedTitle=""
3636
closedMessage="Click on the icon to reopen"
3737
/>

components/Cards.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ import readingTime from 'reading-time';
55
import { sliceText } from '../utils/card';
66
import { formatDate } from '../utils/date';
77

8-
const Cards = ({ post }) => {
8+
interface Props {
9+
post: {
10+
content: string;
11+
cover: {
12+
url: string;
13+
};
14+
id: string;
15+
title: string;
16+
date?: Date;
17+
};
18+
}
19+
20+
const Cards: React.FC<Props> = ({ post }) => {
921
const stats = readingTime(post.content);
1022
return (
1123
<CardWrapper>

components/CodeBlock.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react';
22
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
33
import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism';
44

5-
const CodeBlock = ({ language, value }) => {
5+
interface Props {
6+
language: any;
7+
value: any;
8+
}
9+
10+
const CodeBlock: React.FC<Props> = ({ language, value }) => {
611
return (
712
<SyntaxHighlighter language={language} style={tomorrow}>
813
{value}

components/Contact.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'react-icons/fa';
99
import { fadeInUp, stagger } from '../utils/animate';
1010

11-
const Contact = () => {
11+
const Contact: React.FC = () => {
1212
return (
1313
<motion.div
1414
exit={{ opacity: 0 }}
@@ -22,8 +22,7 @@ const Contact = () => {
2222
<motion.p variants={fadeInUp}>
2323
Hi there, you can reach me by follow my social media or email me at
2424
[email protected]. I am quite active at Facebook and Instagram,
25-
feel free to leave me a message or ask me some question about
26-
science or tech :)
25+
feel free to leave me a message :)
2726
</motion.p>
2827
</div>
2928
<motion.div variants={fadeInUp} className="icons">

components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import styled from 'styled-components';
22
import { motion } from 'framer-motion';
33
import { fadeInUp } from '../utils/animate';
44

5-
const Footer = () => {
5+
const Footer: React.FC = () => {
66
return (
77
<FooterWrapper>
88
<motion.p

components/Navbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { motion } from 'framer-motion';
66
import { FiSun, FiMoon } from 'react-icons/fi';
77
import { fadeInDown } from '../utils/animate';
88

9-
interface Navbar {
9+
interface Props {
1010
active?: boolean;
1111
title?: string;
1212
}
1313

14-
const Navbar = (props: Navbar) => {
14+
const Navbar: React.FC<Props> = (props) => {
1515
const router = useRouter();
1616
const { theme, setTheme } = useTheme();
1717
return (
@@ -119,7 +119,7 @@ const NavbarItems = styled.nav`
119119
font-size: 1rem;
120120
text-transform: uppercase;
121121
font-weight: 500;
122-
background-color: #101012;
122+
background-color: #202020;
123123
border-radius: 4px;
124124
color: white;
125125
padding: 0 8px;

pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ const GlobalStyle = createGlobalStyle`
4848
}
4949
5050
[data-theme='dark'] {
51-
--background: #050505;
52-
--backgroundPost: #050505;
51+
--background: #181818;
52+
--backgroundPost: #181818;
5353
--colorPrimary:rgba(229, 231, 235, 1);
5454
--colorSecondary:rgba(229, 231, 235, 1);
5555
--colorTertiary: rgba(209, 213, 219, 1);
5656
--colorQuarternary: rgba(243, 244, 246, 1);
57-
--navColor: #101012;
57+
--navColor: #202020;
5858
--navHoverColor: #e200e2;
5959
--linkColor:#e200e2;
6060

pages/about.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Footer from '../components/Footer';
33
import AboutContent from '../components/About';
44
import Navbar from '../components/Navbar';
55

6-
const About = () => {
6+
const About: React.FC = () => {
77
return (
88
<>
99
<Head>

pages/contact.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Navbar from '../components/Navbar';
33
import ContactContent from '../components/Contact';
44
import Footer from '../components/Footer';
55

6-
const Contact = () => {
6+
const Contact: React.FC = () => {
77
return (
88
<>
99
<Head>

pages/post/[id].tsx

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect } from 'react';
22
import Head from 'next/head';
33
import Image from 'next/image';
4-
import { useRouter } from 'next/router';
4+
import { NextRouter, useRouter } from 'next/router';
55
import styled from 'styled-components';
66
import { motion } from 'framer-motion';
77
import ReactMarkdown from 'react-markdown';
@@ -10,44 +10,34 @@ import Navbar from '../../components/Navbar';
1010
import Footer from '../../components/Footer';
1111
import CodeBlock from '../../components/CodeBlock';
1212
import { formatDate } from '../../utils/date';
13+
import { fadeInUp, stagger } from '../../utils/animate';
1314

14-
export default function Post({ post }) {
15-
const router = useRouter();
15+
interface Post {
16+
post: {
17+
title: string;
18+
content: string;
19+
cover: {
20+
name?: string;
21+
url: string;
22+
ext?: string;
23+
};
24+
date: Date;
25+
createdAt?: Date;
26+
updatedAt?: Date;
27+
};
28+
}
29+
30+
export default function Post({ post }: Post): JSX.Element {
31+
const router: NextRouter = useRouter();
1632
if (router.isFallback) {
1733
return <div>Loading...</div>;
1834
}
19-
const [navbar, setNavbar] = useState(true);
35+
const [navbar, setNavbar] = useState<boolean>(true);
2036
const stats = readingTime(post.content);
21-
const fadeInUp = {
22-
initial: {
23-
y: 60,
24-
opacity: 0,
25-
},
26-
animate: {
27-
y: 0,
28-
opacity: 1,
29-
transition: {
30-
duration: 0.6,
31-
ease: [0.6, -0.05, 0.01, 0.99],
32-
},
33-
},
34-
};
35-
const stagger = {
36-
animate: {
37-
transition: {
38-
staggerChildren: 0.15,
39-
},
40-
},
41-
};
42-
const LinkRenderer = (props) => {
37+
const LinkRenderer = ({ href, children }) => {
4338
return (
44-
<a
45-
style={{ color: 'blue' }}
46-
href={props.href}
47-
target="_blank"
48-
rel="noopener"
49-
>
50-
{props.children}
39+
<a style={{ color: 'blue' }} href={href} target="_blank" rel="noopener">
40+
{children}
5141
</a>
5242
);
5343
};

0 commit comments

Comments
 (0)