Skip to content

Commit 83acf29

Browse files
committed
Fix resposiveness issue, add disqus API, add loading spinner and add custom 404
Additional changes : - Refactoring react-markdown renderer element to new folder - Add some typescript interfaces - Fix responsiveness issue at index page - Add dark mode to blockquote - Change prism theme to dracula
1 parent b196f5e commit 83acf29

File tree

18 files changed

+2916
-145
lines changed

18 files changed

+2916
-145
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,20 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/deploym
3838
- [ ] Error when bad user open route that not listed by getStaticPath() method on /post/[slug].tsx
3939
- [ ] Navbar logo and darkmode toogle unresponsive on small devices. Can be solved by specifying the correct padding and margin or make flexbox container (I think)
4040
- [ ] Lighthouse performance bug caused by next/Image (Ref: [Lighthouse](https://github.com/GoogleChrome/lighthouse/issues/11631) & [Next.js](https://github.com/vercel/next.js/issues/20611))
41+
- [ ] Translating the page using Microsoft Edge causing card to overflow (`pages/index.tsx`)
4142

4243
## To Do List 👀
4344

4445
- [x] Change data fetching method using GraphQL
4546
- [x] Add dark mode and animation
46-
- [ ] Add Disqus API for comment section
47+
- [x] Add Disqus API for comment section
4748
- [ ] Add readmore at the end of the post
4849
- [ ] Add portfolio page
49-
- [ ] Add custom loading spinner
50-
- [ ] Improve SEO
50+
- [x] Add custom loading spinner
51+
- [x] Improve SEO
5152
- [ ] Improve best practice
5253
- [ ] Reach perfect score on lighthouse
53-
- [ ] Add custom 404 error and 500 error
54+
- [x] Add custom 404 error and 500 error
5455
- [ ] Test some **possible** security vulnerabilities using ZAP & BurpSuite
55-
- [ ] Add typescript interfaces to prevent future bug
56-
- [ ] Add code tag renderer for `react-markdown`
56+
- [x] Add typescript interfaces to prevent future bug
57+
- [x] Add code tag renderer for `react-markdown`

components/About.jsx renamed to components/About.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import Terminal from 'terminal-in-react';
44

55
class AboutContent extends Component {
66
about = () =>
7-
"Hi there! I'm Mekel Ilyasa. A computer nerd who love to learn all things from frontend into backend & security xD. I'm programmer, I have no life, I spend almost all my entire time in front of my computer LMAO. I do programming not because want expect to get paid or get adulation by the public, but because it is fun to program, yup I follow Linus Torvalds ideology LOL. There's no fancy animation or design in this blog, I make this blog simple and lightweight as possible to boost the performance :) ";
7+
"Hi there! I'm Mekel Ilyasa. A computer nerd who loves to learn all things from frontend into backend xD. I'm a programmer, I have no life, I spend almost all my entire time in front of my computer LMAO. I do programming not because want expect to get paid or get adulation by the public, but because it is fun to program, yup I follow one of the quotes from Linus Torvalds 👀 There's no fancy animation or design in this blog, I make this blog simple and lightweight as possible to boost the performance 👻";
88
education = () =>
9-
"I'm currently pursuing my bachelor degree at Computer Engineering Departement, Diponegoro University. I know, majoring 'IT' at college sucks af but I try my best to survive with old school tech stack at college LOL. I code using PHP and Java too at college even I hate it.";
9+
"I'm currently pursuing my bachelor's degree at Computer Engineering Department, Diponegoro University. I know, majoring 'tech' at college sucks but I try my best to survive with old school tech stack at college LOL. I code using PHP and Java too at college even though I hate it 🐳";
1010
skills = () =>
11-
'My main skills are Python & Javascript, but sometimes I also tinkering with low level language like C, C++ & assembly too. My fav tech stack are MERN (MongoDB, Express, React, Node.js) stack. You can visit my github to see all my works and my favorite tech stack. Right now I still exploring an adventure to learn Go programming language to build robust backend services and learn SSR stuff using Next.js.';
11+
'My main skills are Python & Javascript, but sometimes I also tinkering with low level languages like C, C++ & assembly too. My fav tech stack is MERN (MongoDB, Express, React, Node.js) stack. You can visit my GitHub to see all my works and my favorite tech stack. Right now I still exploring an adventure to learn Go programming language to build robust backend services and learn SSR stuff using Next.js 🐙';
1212

1313
render() {
1414
return (
@@ -32,8 +32,6 @@ class AboutContent extends Component {
3232
skills: this.skills,
3333
}}
3434
msg="Hi! Welcome to about page - Type 'help' to list all supported commands"
35-
closedTitle=""
36-
closedMessage="Click on the icon to reopen"
3735
/>
3836
</div>
3937
</AboutWrapper>

components/Cards.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Image from 'next/image';
22
import Link from 'next/link';
33
import styled from 'styled-components';
44
import readingTime from 'reading-time';
5-
import { sliceText } from '../utils/card';
5+
import { sliceText } from '../utils/slice';
66
import { formatDate } from '../utils/date';
77

88
interface Props {
@@ -62,27 +62,25 @@ const Cards: React.FC<Props> = ({ post }) => {
6262
};
6363

6464
const CardWrapper = styled.div`
65+
margin: 0 auto;
66+
max-width: 900px;
6567
padding: 1rem 2rem;
68+
.card-cover-image {
69+
object-fit: cover;
70+
width: 426px;
71+
height: 240px;
72+
@media (max-width: 768px) {
73+
width: 350px;
74+
height: 260px;
75+
}
76+
}
6677
.card-container {
6778
margin: 0 auto;
6879
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
6980
0 2px 4px -1px rgba(0, 0, 0, 0.06);
7081
border-radius: 0.75rem;
7182
overflow: hidden;
72-
@media (min-width: 590px) {
73-
height: auto;
74-
display: flex;
75-
flex-direction: row;
76-
}
7783
@media (min-width: 768px) {
78-
width: 80%;
79-
height: auto;
80-
display: flex;
81-
flex-direction: row;
82-
}
83-
@media (min-width: 1024px) {
84-
width: 60%;
85-
height: auto;
8684
display: flex;
8785
flex-direction: row;
8886
}

components/elements/Anchor.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
interface Props {
2+
href: string;
3+
}
4+
5+
const Anchor: React.FC<Props> = ({ href, children }) => {
6+
return (
7+
<a style={{ color: 'blue' }} href={href} target="_blank" rel="noopener">
8+
{children}
9+
</a>
10+
);
11+
};
12+
13+
export default Anchor;

components/elements/BlockQuote.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import styled from 'styled-components';
2+
3+
interface Props {
4+
children: string;
5+
}
6+
7+
const BlockQuote: React.FC<Props> = ({ children }) => {
8+
return <BlockQuoteContainer>{children}</BlockQuoteContainer>;
9+
};
10+
11+
const BlockQuoteContainer = styled.blockquote`
12+
color: var(--colorPrimary);
13+
margin: 0;
14+
padding-left: 1em;
15+
border-left: 0.4em var(--border) solid;
16+
background: var(--quoteBackground);
17+
`;
18+
19+
export default BlockQuote;

components/CodeBlock.tsx renamed to components/elements/CodeBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
3-
import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism';
3+
import { dracula } from 'react-syntax-highlighter/dist/cjs/styles/prism';
44

55
interface Props {
66
language: any;
77
value: any;
88
}
99

10-
const CodeBlock: React.FC<Props> = ({ language, value }) => {
10+
const CodeBlock: React.FC<Props> = ({ value }) => {
1111
return (
12-
<SyntaxHighlighter language={language} style={tomorrow}>
12+
<SyntaxHighlighter language="python" style={dracula} wrapLines>
1313
{value}
1414
</SyntaxHighlighter>
1515
);

components/elements/Image.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styled from 'styled-components';
2+
3+
const Image: React.FC = (props) => {
4+
return <ImageWrapper {...props} id="post-image" />;
5+
};
6+
7+
const ImageWrapper = styled.img`
8+
margin: 1rem 0;
9+
max-width: 100%;
10+
`;
11+
12+
export default Image;

components/elements/Spinner.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import styled from 'styled-components';
2+
import Loader from 'react-loader-spinner';
3+
import 'react-loader-spinner/dist/loader/css/react-spinner-loader.css';
4+
5+
const Spinner: React.FC = () => {
6+
return (
7+
<SpinnerContainer>
8+
<Loader type="Bars" color="#e200e2" height={50} width={50} />
9+
</SpinnerContainer>
10+
);
11+
};
12+
13+
const SpinnerContainer = styled.div`
14+
position: absolute;
15+
left: 50%;
16+
top: 50%;
17+
transform: translate(-50%, -50%);
18+
`;
19+
20+
export default Spinner;

lib/graphql/queries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GraphQLClient, gql } from 'graphql-request';
33

44
const client = new GraphQLClient(process.env.NEXT_PUBLIC_STRAPI_GRAPHQL_URL);
55

6-
export const getAllPosts = () => {
6+
export const getAllPosts: () => Promise<any> = () => {
77
const query = gql`
88
{
99
posts(sort: "date:desc") {
@@ -21,7 +21,7 @@ export const getAllPosts = () => {
2121
return client.request(query);
2222
};
2323

24-
export const getPostById = (slug) => {
24+
export const getPostById: (slug: string) => Promise<any> = (slug) => {
2525
const query = gql`
2626
{
2727
posts(where: { slug: "${slug}" }) {

0 commit comments

Comments
 (0)