Skip to content

Commit 59bd839

Browse files
authored
🎨 - Improves prettier format (#37)
1 parent fedf742 commit 59bd839

File tree

12 files changed

+182
-180
lines changed

12 files changed

+182
-180
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const config = { autoAddCss: false }
1+
export const config = { autoAddCss: false }

__mocks__/next/font/google.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { vi } from "vitest";
1+
import { vi } from 'vitest'
22

3-
export const Roboto = vi.fn(()=> {
3+
export const Roboto = vi.fn(() => {
44
return {
55
weight: ['400', '700'],
66
subsets: ['latin'],
77
variable: '--font-roboto',
88
}
9-
});
9+
})
1010

11-
export const Khula = vi.fn(()=> {
11+
export const Khula = vi.fn(() => {
1212
return {
1313
weight: ['400'],
1414
subsets: ['latin'],
1515
variable: '--font-inter',
1616
}
17-
});
17+
})

__mocks__/next/navigation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vi } from 'vitest'
2-
3-
// __mocks__/next/navigation.js
4-
export const notFound = vi.fn(() => {})
1+
import { vi } from 'vitest'
2+
3+
// __mocks__/next/navigation.js
4+
export const notFound = vi.fn(() => {})

__test__/_app/Layout.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import Layout from '../../src/app/layout'
55

66
describe('Layout', () => {
77
it('should render layout', () => {
8-
const component = render(<Layout>
9-
<h1>Layout Testing</h1>
10-
</Layout>)
8+
const component = render(
9+
<Layout>
10+
<h1>Layout Testing</h1>
11+
</Layout>
12+
)
1113
expect(component).toBeDefined()
1214
})
1315

__test__/_app/Loading.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, it, describe } from 'vitest'
2-
import { render, screen } from "@testing-library/react"
2+
import { render, screen } from '@testing-library/react'
33
import Loading from '../../src/app/loading'
44

55
describe('Loading', () => {
@@ -11,4 +11,4 @@ describe('Loading', () => {
1111
render(<Loading />)
1212
expect(screen.getByText('Loading...')).toBeTruthy()
1313
})
14-
})
14+
})

__test__/_app/Page.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it} from 'vitest'
1+
import { describe, expect, it } from 'vitest'
22
import Page from '../../src/app/page'
33
import { render, screen } from '@testing-library/react'
44

@@ -8,8 +8,7 @@ describe('Page', () => {
88
expect(component).toBeDefined()
99
})
1010
it('should render blog title', () => {
11-
1211
render(<Page />)
1312
expect(screen.getByText('Blog')).toBeDefined()
1413
})
15-
})
14+
})

__test__/_app/[slug]/Page.test.tsx

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import { describe, expect, it } from 'vitest'
2-
import BlogPage, { generateMetadata } from '../../../src/app/[slug]/page'
3-
import { render } from '@testing-library/react'
4-
5-
describe('PageSlug', () => {
6-
it('Should render', async () => {
7-
const jsx = await BlogPage({
8-
params: { slug: 'resources_developers' },
9-
})
10-
const component = render(jsx)
11-
expect(component).toBeDefined()
12-
})
13-
})
14-
15-
describe('generateMetadata', () => {
16-
it('Should return metadata', async () => {
17-
const metadata = await generateMetadata({
18-
params: { slug: 'resources_developers' },
19-
})
20-
expect(metadata).toEqual({
21-
description:
22-
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
23-
openGraph: {
24-
description:
25-
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
26-
images: 'https://claudiocoder.me/profile.jpg',
27-
locale: 'es',
28-
siteName: 'claudiocoder.me',
29-
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
30-
url: 'https://claudiocoder.me/resources_developers',
31-
},
32-
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
33-
twitter: {
34-
card: 'summary_large_image',
35-
description:
36-
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
37-
images: 'https://claudiocoder.me/profile.jpg',
38-
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
39-
},
40-
})
41-
})
42-
})
1+
import { describe, expect, it } from 'vitest'
2+
import BlogPage, { generateMetadata } from '../../../src/app/[slug]/page'
3+
import { render } from '@testing-library/react'
4+
5+
describe('PageSlug', () => {
6+
it('Should render', async () => {
7+
const jsx = await BlogPage({
8+
params: { slug: 'resources_developers' },
9+
})
10+
const component = render(jsx)
11+
expect(component).toBeDefined()
12+
})
13+
})
14+
15+
describe('generateMetadata', () => {
16+
it('Should return metadata', async () => {
17+
const metadata = await generateMetadata({
18+
params: { slug: 'resources_developers' },
19+
})
20+
expect(metadata).toEqual({
21+
description:
22+
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
23+
openGraph: {
24+
description:
25+
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
26+
images: 'https://claudiocoder.me/profile.jpg',
27+
locale: 'es',
28+
siteName: 'claudiocoder.me',
29+
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
30+
url: 'https://claudiocoder.me/resources_developers',
31+
},
32+
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
33+
twitter: {
34+
card: 'summary_large_image',
35+
description:
36+
'Mis 5 Sitios Favoritos para Aprender Programación | @claudio_coder',
37+
images: 'https://claudiocoder.me/profile.jpg',
38+
title: 'Mis 5 Sitios Favoritos para Aprender Programación',
39+
},
40+
})
41+
})
42+
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"format": "prettier --check .",
1111
"format:fix": "prettier --write .",
1212
"test": "vitest",
13-
"test:coverage": "vitest --coverage"
13+
"test:coverage": "vitest --coverage"
1414
},
1515
"dependencies": {
1616
"@fortawesome/fontawesome-svg-core": "^6.5.1",

src/app/[slug]/page.tsx

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
import { allBlogs } from 'contentlayer/generated'
2-
import { notFound } from 'next/navigation'
3-
import { format, parseISO } from 'date-fns'
4-
import Footer from '@/components/Footer'
5-
import { Mdx } from '@/components/Mdx'
6-
import metadata from '@/utils/metadata'
7-
import SocialMediaScripts from '@/components/SocialMediaScripts'
8-
9-
type Props = {
10-
params: {
11-
slug: string
12-
}
13-
}
14-
15-
const getDocFromParams = ({ params }: Props) => {
16-
const doc = allBlogs.find(doc => doc.slug === params.slug)
17-
18-
return doc ?? null
19-
}
20-
21-
export const generateMetadata = async ({ params }: Props) => {
22-
const doc = await getDocFromParams({ params })
23-
if (!doc) {
24-
return {}
25-
}
26-
return metadata({
27-
title: doc.title,
28-
description: doc.description,
29-
path: `/${doc.slug}`,
30-
image: `/${doc.thumbnailUrl}`,
31-
})
32-
}
33-
34-
const BlogPage = async ({ params }: Props) => {
35-
const post = await getDocFromParams({ params })
36-
if (!post) {
37-
notFound()
38-
}
39-
40-
return (
41-
<div className='flex flex-col my-8 sm:px-[5%]'>
42-
<div className='mx-4'>
43-
<div className='sm:pl-[5%] sm:pr-[15%] mb-4 sm:mb-8'>
44-
<h1 className='text-2xl sm:text-4xl font-black'>{post.title}</h1>
45-
<time
46-
dateTime={post.date}
47-
className='my-2 block text-sm w-full text-gray-600 text-left'
48-
>
49-
{format(parseISO(post.date), 'MMMM dd, yyyy')}
50-
</time>
51-
<p className='text-gray-500 italic text-sm'>{post.author}</p>
52-
53-
<div className='my-2'>
54-
<a
55-
href='https://twitter.com/share?ref_src=twsrc%5Etfw'
56-
className='twitter-share-button'
57-
data-show-count='false'
58-
>
59-
<span>Compartir en X</span>
60-
</a>
61-
</div>
62-
</div>
63-
<div className='sm:pl-[5%] sm:pr-[15%] h-[70vh] mb-4'>
64-
<Mdx code={post.body.code} />
65-
</div>
66-
</div>
67-
<div className='border-t-2 border-solid py-5 px-4 fixed bg-white w-full bottom-0'>
68-
<Footer />
69-
</div>
70-
<SocialMediaScripts />
71-
</div>
72-
)
73-
}
74-
75-
export default BlogPage
1+
import { allBlogs } from 'contentlayer/generated'
2+
import { notFound } from 'next/navigation'
3+
import { format, parseISO } from 'date-fns'
4+
import Footer from '@/components/Footer'
5+
import { Mdx } from '@/components/Mdx'
6+
import metadata from '@/utils/metadata'
7+
import SocialMediaScripts from '@/components/SocialMediaScripts'
8+
9+
type Props = {
10+
params: {
11+
slug: string
12+
}
13+
}
14+
15+
const getDocFromParams = ({ params }: Props) => {
16+
const doc = allBlogs.find(doc => doc.slug === params.slug)
17+
18+
return doc ?? null
19+
}
20+
21+
export const generateMetadata = async ({ params }: Props) => {
22+
const doc = await getDocFromParams({ params })
23+
if (!doc) {
24+
return {}
25+
}
26+
return metadata({
27+
title: doc.title,
28+
description: doc.description,
29+
path: `/${doc.slug}`,
30+
image: `/${doc.thumbnailUrl}`,
31+
})
32+
}
33+
34+
const BlogPage = async ({ params }: Props) => {
35+
const post = await getDocFromParams({ params })
36+
if (!post) {
37+
notFound()
38+
}
39+
40+
return (
41+
<div className='flex flex-col my-8 sm:px-[5%]'>
42+
<div className='mx-4'>
43+
<div className='sm:pl-[5%] sm:pr-[15%] mb-4 sm:mb-8'>
44+
<h1 className='text-2xl sm:text-4xl font-black'>{post.title}</h1>
45+
<time
46+
dateTime={post.date}
47+
className='my-2 block text-sm w-full text-gray-600 text-left'
48+
>
49+
{format(parseISO(post.date), 'MMMM dd, yyyy')}
50+
</time>
51+
<p className='text-gray-500 italic text-sm'>{post.author}</p>
52+
53+
<div className='my-2'>
54+
<a
55+
href='https://twitter.com/share?ref_src=twsrc%5Etfw'
56+
className='twitter-share-button'
57+
data-show-count='false'
58+
>
59+
<span>Compartir en X</span>
60+
</a>
61+
</div>
62+
</div>
63+
<div className='sm:pl-[5%] sm:pr-[15%] h-[70vh] mb-4'>
64+
<Mdx code={post.body.code} />
65+
</div>
66+
</div>
67+
<div className='border-t-2 border-solid py-5 px-4 fixed bg-white w-full bottom-0'>
68+
<Footer />
69+
</div>
70+
<SocialMediaScripts />
71+
</div>
72+
)
73+
}
74+
75+
export default BlogPage

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"**/*.ts",
3030
"**/*.tsx",
3131
".next/types/**/*.ts",
32-
".contentlayer/generated"
32+
".contentlayer/generated",
33+
"__tests__/**/*"
3334
],
3435
"exclude": ["node_modules"]
3536
}

0 commit comments

Comments
 (0)