Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dak2 committed Jul 15, 2023
1 parent 1b1368d commit 48f1f49
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 82 deletions.
60 changes: 36 additions & 24 deletions components/atoms/genericIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
import { FaGithub, FaAws, FaDocker, FaChevronLeft, FaChevronRight, FaRust, FaNodeJs, FaReact, FaBookOpen } from 'react-icons/fa';
import { SiJavascript, SiRuby, SiRubyonrails, SiTypescript, SiDeno } from 'react-icons/si';
import {
FaGithub,
FaAws,
FaDocker,
FaChevronLeft,
FaChevronRight,
FaRust,
FaNodeJs,
FaReact,
FaBookOpen,
} from 'react-icons/fa';
import {
SiJavascript,
SiRuby,
SiRubyonrails,
SiTypescript,
SiDeno,
} from 'react-icons/si';

type Props = {
iconName: string;
styleName?: string;
}
};

const GenericIcon = (props: Props) => {
const iconName = props.iconName;
const styleName = props.styleName;
const icons = {
'aws': <FaAws/>,
'docker': <FaDocker/>,
'github': <FaGithub/>,
'javascript': <SiJavascript/>,
'typescript': <SiTypescript/>,
'nodejs': <FaNodeJs/>,
'react': <FaReact/>,
'ruby': <SiRuby/>,
'ruby-on-rails': <SiRubyonrails/>,
'rust': <FaRust/>,
'deno': <SiDeno/>,
'right': <FaChevronRight/>,
'left': <FaChevronLeft/>,
'book': <FaBookOpen/>,
}
aws: <FaAws />,
docker: <FaDocker />,
github: <FaGithub />,
javascript: <SiJavascript />,
typescript: <SiTypescript />,
nodejs: <FaNodeJs />,
react: <FaReact />,
ruby: <SiRuby />,
'ruby-on-rails': <SiRubyonrails />,
rust: <FaRust />,
deno: <SiDeno />,
right: <FaChevronRight />,
left: <FaChevronLeft />,
book: <FaBookOpen />,
};

return (
<div className={styleName}>
{icons[iconName]}
</div>
)
}
return <div className={styleName}>{icons[iconName]}</div>;
};

export default GenericIcon;
10 changes: 7 additions & 3 deletions components/molecules/headerBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import GenericIcon from '../atoms/genericIcon';

const HeaderBar = () => {
return (
<div id="header" className="flex mb-32 justify-start">
<div id="header" className="flex justify-start mb-32">
<Link href="/">
<h1 className="text-4xl font-bold font-mono mr-96 cursor-pointer text-gray-200">
<h1 className="font-mono text-4xl font-bold text-gray-200 cursor-pointer mr-96">
Kdevlog
</h1>
</Link>
<div id="github-icon-container" className="flex ml-64">
<a id="github-icon" href="https://github.com/dak2" className="text-2xl ml-2">
<a
id="github-icon"
href="https://github.com/dak2"
className="ml-2 text-2xl"
>
<GenericIcon iconName="github" />
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/molecules/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function Layout({ children, home }) {
{!home && currentPageId != 1 && (
<div id="back-page-link" className="my-12">
<Link href="/">
<a className="text-gray-200 hover:underline">← Back to home</a>
<p className="text-gray-200 hover:underline">← Back to home</p>
</Link>
</div>
)}
Expand Down
32 changes: 20 additions & 12 deletions components/molecules/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ const Pagination = ({ totalCount }) => {
const prevPage = () => {
if (pagenationList.length <= 1) {
return (
<div id="prev-page-icon" style={{ marginTop: 5 }}>
<GenericIcon iconName='left'/>
</div>
)
<div id="prev-page-icon" style={{ marginTop: 5 }}>
<GenericIcon iconName="left" />
</div>
);
} else {
return (
<a id="prev-page-icon" href={`/posts/page/${prevPageId}`} style={{ marginTop: 5 }}>
<GenericIcon iconName='left'/>
<a
id="prev-page-icon"
href={`/posts/page/${prevPageId}`}
style={{ marginTop: 5 }}
>
<GenericIcon iconName="left" />
</a>
);
}
Expand All @@ -30,13 +34,17 @@ const Pagination = ({ totalCount }) => {
if (pagenationList.length <= 1 || pagenationList.length === currentPageId) {
return (
<div id="next-page-icon" style={{ marginTop: 5 }}>
<GenericIcon iconName='right'/>
<GenericIcon iconName="right" />
</div>
)
);
} else {
return (
<a id="next-page-icon" href={`/posts/page/${nextPageId}`} style={{ marginTop: 5 }}>
<GenericIcon iconName='right'/>
<a
id="next-page-icon"
href={`/posts/page/${nextPageId}`}
style={{ marginTop: 5 }}
>
<GenericIcon iconName="right" />
</a>
);
}
Expand All @@ -50,10 +58,10 @@ const Pagination = ({ totalCount }) => {
<li
id="page-number"
key={index}
className="mx-1.5 w-6 inline-block text-center hover:underline"
className="inline-block w-6 text-center mx-1.5 hover:underline"
>
<Link href={`/posts/page/${number}`}>
<a>{number}</a>
<p>{number}</p>
</Link>
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const httpRequest = async (url: string, key: any) =>
export const httpRequest = async (url: string, key: RequestInit) =>
fetch(url, key)
.then((response) => response.json())
.catch((error) => error);
24 changes: 20 additions & 4 deletions lib/myHighlight.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import hljs from 'highlight.js/lib/core';
import { RegistLanguages } from '../lib/const';
import javascript from 'highlight.js/lib/languages/javascript';
import typescript from 'highlight.js/lib/languages/typescript';
import go from 'highlight.js/lib/languages/go';
import ruby from 'highlight.js/lib/languages/ruby';
import rust from 'highlight.js/lib/languages/rust';

const languages = {
javascript,
typescript,
go,
ruby,
rust,
};

export const registLanguage = (language: string) => {
if (RegistLanguages.includes(language)) {
hljs.registerLanguage(
`${language}`,
require(`highlight.js/lib/languages/${language}`),
);
const langModule = languages[language];

if (langModule) {
hljs.registerLanguage(language, langModule);
} else {
return false;
}
} else {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const LanguageTypes = [
{ lang: 'rust' },
{ lang: 'deno' },
{ lang: 'go' },
]
];
5 changes: 4 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
8 changes: 4 additions & 4 deletions pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import Link from 'next/link';

export default function Custom404() {
return (
<div className="grid justify-items-center pt-64">
<h1 className="text-5xl mb-10 font-bold">404 - Page Not Found</h1>
<Link href="/">
<a className="text-2xl">→ Go back home</a>
<div className="pt-64 grid justify-items-center">
<h1 className="mb-10 text-5xl font-bold">404 - Page Not Found</h1>
<Link href="/" className="text-2xl">
→ Go back home
</Link>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import '../styles/global.scss';

export default function App({ Component, pageProps }) {
return (
<div id="_app" className="bg-zinc-800 min-h-fit font-sans py-10 text-gray-200">
<div
id="_app"
className="py-10 font-sans text-gray-200 bg-zinc-800 min-h-fit"
>
<Component {...pageProps} />
</div>
);
Expand Down
19 changes: 11 additions & 8 deletions pages/archives/tags/[...params].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const postLists = (props: PropsType) => {
<li key={postIndex}>
<div id="post-sub-container" className="mb-12">
<Link href={`/posts/${id}`}>
<h2 className="text-2xl font-extrabold mb-2">
<a className="cursor-pointer hover:underline">{title}</a>
<h2 className="mb-2 text-2xl font-extrabold">
<p className="cursor-pointer hover:underline">{title}</p>
</h2>
</Link>
<small id="updated-at" className="text-gray-200">
<FormatedDate dateString={updatedAt} />
<FormatedDate dateString={updatedAt} />
</small>
<div>
<ul>
Expand All @@ -50,7 +50,10 @@ const postLists = (props: PropsType) => {
},
}}
>
<p id="tag" className="mr-2 text-sm font-bold cursor-pointer hover:underline">
<p
id="tag"
className="mr-2 text-sm font-bold cursor-pointer hover:underline"
>
#{tag.name}
</p>
</Link>
Expand All @@ -69,7 +72,7 @@ const postLists = (props: PropsType) => {
};

const icon = (tag: string) => {
if(tag) return <GenericIcon iconName={tag} styleName={'mt-2'} />
if (tag) return <GenericIcon iconName={tag} styleName={'mt-2'} />;
return null;
};

Expand All @@ -79,8 +82,8 @@ const noPosts = () => {
<Head>
<title>{siteTitle}</title>
</Head>
<div className="grid justify-items-center pt-64">
<h1 className="text-5xl mb-10 font-bold">記事はありません</h1>
<div className="pt-64 grid justify-items-center">
<h1 className="mb-10 text-5xl font-bold">記事はありません</h1>
</div>
</Layout>
);
Expand All @@ -102,7 +105,7 @@ export const getStaticPaths = async () => {
tag.toLowerCase().replace(/\s+/g, ''),
);
const newPaths = [];
for (let tag of toLowerCaseTags) {
for (const tag of toLowerCaseTags) {
newPaths.push({ params: { params: [tag] } });
}

Expand Down
7 changes: 5 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const postLists = (props: PropsType) => {
<div id="post-sub-container" className="mb-12">
<Link href={`/posts/${id}`}>
<h2 className="mb-2 text-2xl font-extrabold">
<a className="cursor-pointer hover:underline">{title}</a>
<p className="cursor-pointer hover:underline">{title}</p>
</h2>
</Link>
<small id="updated-at" className="text-gray-200">
Expand All @@ -45,7 +45,10 @@ const postLists = (props: PropsType) => {
},
}}
>
<p id="tag" className="mr-2 text-sm font-bold cursor-pointer hover:underline">
<p
id="tag"
className="mr-2 text-sm font-bold cursor-pointer hover:underline"
>
#{tag.name}
</p>
</Link>
Expand Down
Loading

0 comments on commit 48f1f49

Please sign in to comment.