Update dependencies and fix introduced errors

This commit is contained in:
Hazem Krimi
2023-03-19 00:17:48 +01:00
parent fad540e17b
commit c97cb80ce8
19 changed files with 1316 additions and 1311 deletions
+5 -28
View File
@@ -1,37 +1,14 @@
declare module '@mdx-js/react' { declare module '@mdx-js/react' {
import * as React from 'react'; import * as React from 'react';
type ComponentType =
| 'a'
| 'blockquote'
| 'code'
| 'del'
| 'em'
| 'h1'
| 'h2'
| 'h3'
| 'h4'
| 'h5'
| 'h6'
| 'hr'
| 'img'
| 'inlineCode'
| 'li'
| 'ol'
| 'p'
| 'pre'
| 'strong'
| 'sup'
| 'table'
| 'td'
| 'thematicBreak'
| 'tr'
| 'ul';
export type Components = { export type Components = {
[key in ComponentType]?: React.ComponentType<any>; [key]?: React.ComponentType<any>;
}; };
export interface MDXProviderProps { export interface MDXProviderProps {
children: React.ReactNode; children: React.ReactNode;
components: Components; components?: Components;
} }
export class MDXProvider extends React.Component<MDXProviderProps> {} export class MDXProvider extends React.Component<MDXProviderProps> {}
} }
+5 -12
View File
@@ -1,24 +1,17 @@
import { FC, useContext } from 'react';
import { ThemeContext } from '../../styles/theme';
import { Props } from './types'; import { Props } from './types';
import { Btn } from './styles'; import { StyledButton } from './styles';
import Link from 'next/link';
const Button: FC<Props & { className?: string }> = ({ const Button = ({
variant = 'text', variant = 'text',
href, href,
target, target,
onClick, onClick,
children, children,
className className
}) => { }: Props) => (
return ( <StyledButton href={href} target={target} className={className} onClick={onClick} variant={variant}>
<Link href={href} passHref>
<Btn as='a' target={target} variant={variant} onClick={onClick} className={className}>
{children} {children}
</Btn> </StyledButton>
</Link>
); );
};
export default Button; export default Button;
+2 -1
View File
@@ -1,7 +1,8 @@
import styled from 'styled-components'; import styled from 'styled-components';
import Link from 'next/link';
import { Props } from './types'; import { Props } from './types';
export const Btn = styled.button<Omit<Props, 'href'>>` export const StyledButton = styled(Link)<Props>`
position: relative; position: relative;
display: inline; display: inline;
cursor: pointer; cursor: pointer;
+2
View File
@@ -3,4 +3,6 @@ export type Props = {
href: string; href: string;
target?: HTMLAnchorElement['target']; target?: HTMLAnchorElement['target'];
onClick?: () => void; onClick?: () => void;
children: React.ReactNode;
className?: string;
}; };
+2 -5
View File
@@ -1,7 +1,6 @@
import { FC } from 'react'; import { FC } from 'react';
import { StyledCard } from './styles'; import { StyledCard } from './styles';
import Image from 'next/image'; import Image from 'next/image';
import Link from 'next/link';
interface Props { interface Props {
title: string; title: string;
@@ -15,8 +14,7 @@ interface Props {
const Card: FC<Props> = ({ title, description, image, tags, href, target, onClick }) => { const Card: FC<Props> = ({ title, description, image, tags, href, target, onClick }) => {
return ( return (
<Link href={href} passHref> <StyledCard href={href} onClick={onClick} image={!!image} target={target}>
<StyledCard as='a' target={target} onClick={onClick} image={!!image}>
<div className='card-content'> <div className='card-content'>
<h3>{title}</h3> <h3>{title}</h3>
<p>{description}</p> <p>{description}</p>
@@ -30,11 +28,10 @@ const Card: FC<Props> = ({ title, description, image, tags, href, target, onClic
</div> </div>
{image && ( {image && (
<div className='card-image'> <div className='card-image'>
<Image src={image} layout='fill' objectFit='cover' /> <Image alt={title} src={image} fill />
</div> </div>
)} )}
</StyledCard> </StyledCard>
</Link>
); );
}; };
+2 -1
View File
@@ -1,6 +1,7 @@
import styled from 'styled-components'; import styled from 'styled-components';
import Link from 'next/link';
export const StyledCard = styled.div<{ image: boolean }>` export const StyledCard = styled(Link)<{ image: boolean }>`
cursor: pointer; cursor: pointer;
width: 100%; width: 100%;
display: grid; display: grid;
+1 -1
View File
@@ -3,7 +3,7 @@ import Highlight, { defaultProps, Language } from 'prism-react-renderer';
import theme from 'prism-react-renderer/themes/vsDark'; import theme from 'prism-react-renderer/themes/vsDark';
import { Line, LineContent, LineNo, Pre } from './styles'; import { Line, LineContent, LineNo, Pre } from './styles';
const CodeBlock: FC<{ className: string }> = ({ children, className }) => { const CodeBlock: FC<{ className: string, children: React.ReactNode }> = ({ children, className }) => {
const language = className.replace(/language-/, '') as Language; const language = className.replace(/language-/, '') as Language;
return ( return (
+4
View File
@@ -67,6 +67,10 @@ const GlobalStyles = createGlobalStyle`
body::-webkit-scrollbar-thumb { body::-webkit-scrollbar-thumb {
background-color: var(--text) !important; background-color: var(--text) !important;
} }
a {
text-decoration: none;
}
`; `;
export default GlobalStyles; export default GlobalStyles;
+5 -7
View File
@@ -12,7 +12,7 @@ interface Props {
onClick?: () => void; onClick?: () => void;
} }
const Btn = styled.button` const Btn = styled(Link)`
cursor: pointer; cursor: pointer;
background: none; background: none;
border: none; border: none;
@@ -30,15 +30,13 @@ const IconButton: FC<Props & { className?: string }> = ({
height = 24 height = 24
}) => { }) => {
return !href ? ( return !href ? (
<Btn onClick={onClick} className={className}> <Btn href='#' onClick={onClick} className={className}>
<Image src={icon} width={width} height={height} /> <Image alt='' src={icon} width={width} height={height} />
</Btn> </Btn>
) : ( ) : (
<Link href={href} passHref> <Btn href={href} target={target} onClick={onClick} className={className}>
<Btn as='a' target={target} onClick={onClick} className={className}> <Image alt='' src={icon} width={width} height={height} />
<Image src={icon} width={width} height={height} />
</Btn> </Btn>
</Link>
); );
}; };
+5 -8
View File
@@ -1,10 +1,9 @@
import { FC, useContext } from 'react'; import { useContext } from 'react';
import { ThemeContext } from '../../styles/theme'; import { ThemeContext } from '../../styles/theme';
import { Props } from './types'; import { Props } from './types';
import { Btn } from './styles'; import { Btn } from './styles';
import Link from 'next/link';
const MDXButton: FC<Props & { className?: string }> = ({ const MDXButton = ({
variant = 'text', variant = 'text',
type = 'button', type = 'button',
link, link,
@@ -12,13 +11,12 @@ const MDXButton: FC<Props & { className?: string }> = ({
children, children,
disabled, disabled,
className className
}) => { }: Props) => {
const { mode } = useContext(ThemeContext); const { mode } = useContext(ThemeContext);
return link ? ( return link ? (
<Link href={link} passHref>
<Btn <Btn
as='a' href={link}
target={target} target={target}
variant={variant} variant={variant}
type={type} type={type}
@@ -28,9 +26,8 @@ const MDXButton: FC<Props & { className?: string }> = ({
> >
{children} {children}
</Btn> </Btn>
</Link>
) : ( ) : (
<Btn variant={variant} type={type} mode={mode} disabled={disabled} className={className}> <Btn href="#" variant={variant} type={type} mode={mode} disabled={disabled} className={className}>
{children} {children}
</Btn> </Btn>
); );
+2 -1
View File
@@ -1,7 +1,8 @@
import Link from 'next/link';
import styled from 'styled-components'; import styled from 'styled-components';
import { Props } from './types'; import { Props } from './types';
export const Btn = styled.button<Props>` export const Btn = styled(Link)<Props>`
cursor: pointer; cursor: pointer;
display: ${({ variant }) => display: ${({ variant }) =>
['action', 'outline'].includes(variant as string) ? 'block' : 'inline'}; ['action', 'outline'].includes(variant as string) ? 'block' : 'inline'};
+2
View File
@@ -5,4 +5,6 @@ export type Props = {
target?: HTMLAnchorElement['target']; target?: HTMLAnchorElement['target'];
mode?: string; mode?: string;
disabled?: boolean; disabled?: boolean;
className?: string;
children: React.ReactNode;
}; };
+1 -3
View File
@@ -13,8 +13,7 @@ const Nav: FC = () => {
return ( return (
<Bar> <Bar>
<Link href='/' passHref> <Link className='logo' href='/'>
<a className='logo'>
<Image <Image
className='logo-image' className='logo-image'
src={mode === 'dark' ? '/light-logo.svg' : '/dark-logo.svg'} src={mode === 'dark' ? '/light-logo.svg' : '/dark-logo.svg'}
@@ -23,7 +22,6 @@ const Nav: FC = () => {
height={48} height={48}
/> />
<h1>Hazem Krimi</h1> <h1>Hazem Krimi</h1>
</a>
</Link> </Link>
<div className='buttons'> <div className='buttons'>
<IconButton <IconButton
-14
View File
@@ -1,14 +0,0 @@
import { CodePen, Gist, YouTube, CodeSandbox, Vimeo, Tweet } from 'mdx-embed';
import Image from 'next/image';
import MDXButton from './MDXButton';
export default {
Button: MDXButton,
Image,
CodePen,
Gist,
Vimeo,
CodeSandbox,
Tweet,
YouTube
};
+4 -1
View File
@@ -1,5 +1,8 @@
const withMDX = require('@next/mdx')({ const withMDX = require('@next/mdx')({
extension: /\.mdx?$/ extension: /\.mdx?$/,
options: {
providerImportSource: '@mdx-js/react'
}
}); });
module.exports = withMDX({ module.exports = withMDX({
+17 -17
View File
@@ -8,28 +8,28 @@
"start": "next start" "start": "next start"
}, },
"dependencies": { "dependencies": {
"@formspree/react": "^2.2.3", "@formspree/react": "^2.4.1",
"@mdx-js/loader": "^1.6.22", "@mdx-js/loader": "^2.3.0",
"@next/mdx": "^12.0.8", "@next/mdx": "^13.2.4",
"gray-matter": "^4.0.2", "gray-matter": "^4.0.3",
"mdx-embed": "^0.0.22", "mdx-embed": "^1.1.2",
"next": "^12.0.8", "next": "^13.2.4",
"next-mdx-remote": "^3.0.8", "next-mdx-remote": "^4.4.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"prism-react-renderer": "^1.1.1", "prism-react-renderer": "^1.3.5",
"react": "17.0.2", "react": "18.2.0",
"react-dom": "17.0.2", "react-dom": "18.2.0",
"reading-time": "^1.4.0", "reading-time": "^1.5.0",
"styled-components": "^5.2.1" "styled-components": "^5.3.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^17.0.8", "@types/node": "^18.15.3",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@types/react": "^17.0.38", "@types/react": "^18.0.28",
"@types/styled-components": "^5.1.20", "@types/styled-components": "^5.1.26",
"babel-plugin-styled-components": "^2.0.2", "babel-plugin-styled-components": "^2.0.7",
"babel-runtime": "^6.26.0", "babel-runtime": "^6.26.0",
"typescript": "^4.5.4" "typescript": "^5.0.2"
}, },
"engines": { "engines": {
"node": ">=14.x" "node": ">=14.x"
+5 -4
View File
@@ -8,7 +8,6 @@ import { GetStaticPaths, GetStaticProps } from 'next';
import { serialize } from 'next-mdx-remote/serialize'; import { serialize } from 'next-mdx-remote/serialize';
import { Wrapper } from '../../styles/blog/slug'; import { Wrapper } from '../../styles/blog/slug';
import matter from 'gray-matter'; import matter from 'gray-matter';
import components from '../../components';
import Head from 'next/head'; import Head from 'next/head';
import IconButton from '../../components/IconButton'; import IconButton from '../../components/IconButton';
import CodeBlock from '../../components/CodeBlock'; import CodeBlock from '../../components/CodeBlock';
@@ -24,6 +23,8 @@ interface Props {
const BlogPost: FC<Props> = ({ source, frontMatter, text }) => { const BlogPost: FC<Props> = ({ source, frontMatter, text }) => {
const router = useRouter(); const router = useRouter();
const stats = readingTime(text); const stats = readingTime(text);
const htmlOverrides = { code: CodeBlock };
const mdxComponents = {};
useEffect(() => { useEffect(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);
@@ -83,15 +84,15 @@ const BlogPost: FC<Props> = ({ source, frontMatter, text }) => {
) : null} ) : null}
{frontMatter?.image ? ( {frontMatter?.image ? (
<div className='image'> <div className='image'>
<Image src={frontMatter.image} width='100%' height='100%' layout='responsive' /> <Image alt={frontMatter?.title} src={frontMatter.image} fill />
</div> </div>
) : null} ) : null}
<hr /> <hr />
</div> </div>
<MDXProvider components={{ code: CodeBlock }}> <MDXProvider components={{ ...htmlOverrides, ...mdxComponents }}>
<MDXEmbedProvider> <MDXEmbedProvider>
<div className='content'> <div className='content'>
<MDXRemote {...source} components={components} /> <MDXRemote {...source} />
</div> </div>
</MDXEmbedProvider> </MDXEmbedProvider>
</MDXProvider> </MDXProvider>
+5 -7
View File
@@ -3,11 +3,9 @@ import { getPortfolioPorjectsSlugs, getPortfolioProjectdata } from '../../utils/
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'; import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote';
import { MDXProvider } from '@mdx-js/react'; import { MDXProvider } from '@mdx-js/react';
import { MDXEmbedProvider } from 'mdx-embed';
import { GetStaticPaths, GetStaticProps } from 'next'; import { GetStaticPaths, GetStaticProps } from 'next';
import { serialize } from 'next-mdx-remote/serialize'; import { serialize } from 'next-mdx-remote/serialize';
import matter from 'gray-matter'; import matter from 'gray-matter';
import components from '../../components';
import { Wrapper } from '../../styles/portfolio/slug'; import { Wrapper } from '../../styles/portfolio/slug';
import Head from 'next/head'; import Head from 'next/head';
import IconButton from '../../components/IconButton'; import IconButton from '../../components/IconButton';
@@ -22,6 +20,8 @@ interface Props {
const PortfolioProject: FC<Props> = ({ source, frontMatter }) => { const PortfolioProject: FC<Props> = ({ source, frontMatter }) => {
const router = useRouter(); const router = useRouter();
const htmlOverrides = { code: CodeBlock };
const mdxComponents = { Button: MDXButton };
useEffect(() => { useEffect(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);
@@ -78,15 +78,14 @@ const PortfolioProject: FC<Props> = ({ source, frontMatter }) => {
) : null} ) : null}
{frontMatter?.image && !frontMatter?.hideImage ? ( {frontMatter?.image && !frontMatter?.hideImage ? (
<div className='image'> <div className='image'>
<Image src={frontMatter?.image} width='100%' height='100%' layout='responsive' /> <Image alt={frontMatter?.title} src={frontMatter?.image} fill />
</div> </div>
) : null} ) : null}
<hr /> <hr />
</div> </div>
<MDXProvider components={{ code: CodeBlock }}> <MDXProvider components={{ ...htmlOverrides, ...mdxComponents }}>
<MDXEmbedProvider>
<div className='content'> <div className='content'>
<MDXRemote {...source} components={components} /> <MDXRemote {...source} />
<h1>Showcase</h1> <h1>Showcase</h1>
<div className='showcase-buttons'> <div className='showcase-buttons'>
<MDXButton variant='action' link={frontMatter?.demo} target='_blank'> <MDXButton variant='action' link={frontMatter?.demo} target='_blank'>
@@ -97,7 +96,6 @@ const PortfolioProject: FC<Props> = ({ source, frontMatter }) => {
</MDXButton> </MDXButton>
</div> </div>
</div> </div>
</MDXEmbedProvider>
</MDXProvider> </MDXProvider>
</Wrapper> </Wrapper>
</> </>
+1201 -1155
View File
File diff suppressed because it is too large Load Diff