Skip to content

Commit 2c72668

Browse files
authored
Merge pull request #28 from maxpetretta/dev
Dev
2 parents 12ddfb2 + d9cf5f1 commit 2c72668

33 files changed

+234
-101
lines changed

.eslintrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@ module.exports = {
1111
rules: {
1212
"react/no-unescaped-entities": "off",
1313
},
14+
overrides: [
15+
{
16+
files: ["*.ts", "*.tsx"],
17+
rules: {
18+
"no-undef": "off",
19+
},
20+
},
21+
],
1422
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# next.js
1212
/.next/
1313
/out/
14+
next-env.d.ts
1415

1516
# production
1617
/build

components/Accordion.jsx components/Accordion.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function Accordion({ job }) {
6060
dangerouslySetInnerHTML={{ __html: job.description }}
6161
/>
6262
<ul className="grid grid-cols-3 xs:m-2 md:w-1/3 md:grid-cols-1 md:grid-rows-3">
63-
{job.skills.map((skill) => {
63+
{job.skills.map((skill: string) => {
6464
return (
6565
<li className=" md:ml-6" key={skill}>
6666
<Badge logo={skill} />
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/Header.jsx components/Header.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Link from "next/link"
2-
import Toggle from "./Toggle"
3-
import TabBar from "./TabBar"
41
import { useTheme } from "next-themes"
2+
import Link from "next/link"
53
import { useRouter } from "next/router"
4+
import TabBar from "./TabBar"
5+
import Toggle from "./Toggle"
66

77
export default function Header() {
88
const router = useRouter()
@@ -47,18 +47,20 @@ export default function Header() {
4747
</a>
4848
</Link>
4949
<nav className="flex max-w-lg flex-grow items-center justify-end">
50-
{navigation}
51-
<Toggle
52-
id="toggleTheme"
53-
alt="Toggle dark mode"
54-
onClick={() => {
55-
document.body.classList.add("transition-stop")
56-
setTheme(theme === "dark" ? "light" : "dark")
57-
setTimeout(() => {
58-
document.body.classList.remove("transition-stop")
59-
}, 1000)
60-
}}
61-
/>
50+
<>
51+
{navigation}
52+
<Toggle
53+
id="toggleTheme"
54+
alt="Toggle dark mode"
55+
onClick={() => {
56+
document.body.classList.add("transition-stop")
57+
setTheme(theme === "dark" ? "light" : "dark")
58+
setTimeout(() => {
59+
document.body.classList.remove("transition-stop")
60+
}, 1000)
61+
}}
62+
/>
63+
</>
6264
</nav>
6365
</header>
6466
)

components/Heading.jsx components/Heading.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default function Heading({ tag, children }) {
2-
const HTag = `${tag}`
2+
const HTag = `${tag}` as keyof JSX.IntrinsicElements
33
const anchor = getAnchor(children)
44
const link = `#${anchor}`
55
return (
@@ -16,7 +16,7 @@ export default function Heading({ tag, children }) {
1616
)
1717
}
1818

19-
function getAnchor(text) {
19+
function getAnchor(text: string): string {
2020
return text
2121
.toLowerCase()
2222
.replace(/[^a-z0-9 ]/g, "")
File renamed without changes.

components/Post.jsx components/Post.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import Title from "../components/Title"
2-
import Layout from "../components/Layout"
3-
import PostCard from "../components/PostCard"
1+
import { Post as PostType } from "../lib/types"
2+
import Layout from "./Layout"
3+
import PostCard from "./PostCard"
4+
import Title from "./Title"
45

56
export default function Post({ meta, children }) {
67
return (
@@ -32,7 +33,7 @@ export default function Post({ meta, children }) {
3233
)
3334
}
3435

35-
export function getPostBySlug(slug) {
36+
export function getPostBySlug(slug: string): PostType {
3637
const post = require(`../pages/blog/${slug}.mdx`)
3738

3839
return {
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/Title.jsx components/Title.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function Title({ meta }) {
1111
})}
1212
</time>
1313
<div className="flex">
14-
{meta.tags.map((tag) => {
14+
{meta.tags.map((tag: string) => {
1515
return (
1616
<span className="chip my-1 first:ml-0" key={tag}>
1717
{tag}

components/Toggle.jsx components/Toggle.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export default function Toggle({ id, alt, onClick }) {
22
return (
33
<label
44
className="ml-2 inline-flex h-6 w-10 flex-shrink-0 cursor-pointer rounded-full bg-gray-400 align-middle shadow-inner dark:bg-gray-500 xs:h-7 xs:w-12 md:ml-5"
5-
alt={alt}
65
aria-label={"A toggle controlling " + alt}
76
>
87
<input

lib/jobs.js lib/jobs.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import fs from "fs"
22
import path from "path"
3+
import { Job } from "./types"
34

45
const dataDirectory = path.join(process.cwd(), "/public/data")
56

6-
export function getJobs() {
7-
const file = fs.readFileSync(dataDirectory + "/jobs.json")
7+
export function getJobs(): Job[] {
8+
const file = fs.readFileSync(dataDirectory + "/jobs.json").toString()
89
const jobs = JSON.parse(file)
910

1011
return jobs

lib/posts.js lib/posts.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import fs from "fs"
22
import path from "path"
3+
import { Post } from "./types"
34

45
const postDirectory = path.join(process.cwd(), "/pages/blog")
56

6-
export function getAllPosts() {
7+
export function getAllPosts(): Post[] {
78
const files = fs.readdirSync(postDirectory)
89
const posts = files.map((file) => {
910
const post = require(`../pages/blog/${file}`)
@@ -13,6 +14,6 @@ export function getAllPosts() {
1314
...post.meta,
1415
}
1516
})
16-
17+
console.log(posts)
1718
return posts
1819
}

lib/types.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export type Job = {
2+
id: number
3+
company: string
4+
title: string
5+
startDate: string
6+
endDate: string
7+
location: string
8+
image: string
9+
skills: string[]
10+
description: string
11+
}
12+
13+
export type Post = {
14+
slug: string
15+
title: string
16+
description: string
17+
date: string
18+
tags: string[]
19+
image: string
20+
alt: string
21+
icon: string
22+
related: string
23+
}

next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ const withMDX = require("@next/mdx")({
2828
module.exports = {
2929
...config,
3030
...withMDX({
31-
pageExtensions: ["js", "jsx", "mdx"],
31+
pageExtensions: ["ts", "tsx", "mdx"],
3232
}),
3333
}

package-lock.json

+81-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"shiki": "^0.10.1"
2626
},
2727
"devDependencies": {
28+
"@types/node": "^18.7.16",
29+
"@types/react": "^18.0.19",
2830
"autoprefixer": "^10.4.2",
2931
"eslint": "^8.6.0",
3032
"eslint-config-next": "^12.0.7",
@@ -34,7 +36,8 @@
3436
"postcss": "^8.4.5",
3537
"prettier": "^2.5.1",
3638
"prettier-plugin-tailwindcss": "^0.1.4",
37-
"tailwindcss": "^3.0.13"
39+
"tailwindcss": "^3.0.13",
40+
"typescript": "^4.8.3"
3841
},
3942
"lint-staged": {
4043
"**/*": "prettier --write --ignore-unknown"

pages/404.js pages/404.tsx

File renamed without changes.

pages/_app.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ThemeProvider } from "next-themes"
2+
import type { AppProps } from "next/app"
3+
import "../styles/globals.css"
4+
5+
export default function App({ Component, pageProps }: AppProps) {
6+
return (
7+
<>
8+
<ThemeProvider attribute="class" defaultTheme="light">
9+
<Component {...pageProps} />
10+
</ThemeProvider>
11+
</>
12+
)
13+
}

0 commit comments

Comments
 (0)