Skip to content

Commit

Permalink
feat: implement biome
Browse files Browse the repository at this point in the history
Signed-off-by: mateonunez <mateonunez95@gmail.com>
  • Loading branch information
mateonunez committed Dec 23, 2023
1 parent 8f3c68e commit 18bbed4
Show file tree
Hide file tree
Showing 80 changed files with 738 additions and 4,268 deletions.
7 changes: 2 additions & 5 deletions app/api/open-source/profile/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { getProfile } from 'lib/github';
import { normalizeGitHubProfile } from 'lib/utils/normalizers/normalizeGithub';

export async function GET() {
const profile = await getProfile().catch(err => {
return NextResponse.json(
{ message: 'Something went wrong with GitHub.', extra: err },
{ status: 500 }
);
const profile = await getProfile().catch((err) => {
return NextResponse.json({ message: 'Something went wrong with GitHub.', extra: err }, { status: 500 });
});
if (!profile) {
return NextResponse.json({ error: 'Github not available' }, { status: 500 });
Expand Down
7 changes: 2 additions & 5 deletions app/api/open-source/readme/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { NextResponse } from 'next/server';
import { getReadme } from 'lib/github';

export async function GET() {
const readme = await getReadme().catch(err => {
return NextResponse.json(
{ message: 'Something went wrong with GitHub.', extra: err },
{ status: 500 }
);
const readme = await getReadme().catch((err) => {
return NextResponse.json({ message: 'Something went wrong with GitHub.', extra: err }, { status: 500 });
});
if (!readme) {
return NextResponse.json({ error: 'Github not available' }, { status: 500 });
Expand Down
9 changes: 3 additions & 6 deletions app/api/open-source/repositories/[slug]/route.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { NextResponse } from 'next/server';
import { getRepository } from 'lib/github';

export async function GET(request, { params }) {
export async function GET(_, { params }) {
const { slug: repository } = params;
if (!repository) {
return NextResponse.json({ error: 'Repository not found' }, { status: 404 });
}

const { [repository]: repositoryFetched } = await getRepository(repository).catch(err => {
return NextResponse.json(
{ message: 'Something went wrong with GitHub.', extra: err },
{ status: 500 }
);
const { [repository]: repositoryFetched } = await getRepository(repository).catch((err) => {
return NextResponse.json({ message: 'Something went wrong with GitHub.', extra: err }, { status: 500 });
});

if (!repositoryFetched) {
Expand Down
2 changes: 1 addition & 1 deletion app/api/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const { author } = metadata;

export async function GET() {
return NextResponse.json({
...author
...author,
});
}
2 changes: 1 addition & 1 deletion app/api/spotify/recently-played/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getRecentlyPlayed } from 'lib/spotify';
import { normalizeRecentlyPlayed } from 'lib/utils/normalizers';

export async function GET() {
const response = await getRecentlyPlayed().catch(err => {
const response = await getRecentlyPlayed().catch((err) => {
return NextResponse.json({ recently_played: false, message: 'Are you connected?', extra: err });
});

Expand Down
6 changes: 3 additions & 3 deletions app/api/spotify/top/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { getTopArtists, getTopTracks } from 'lib/spotify';
import { normalizeArtists, normalizeTracks } from 'lib/utils/normalizers';

export async function GET() {
const artistsResponse = await getTopArtists().catch(err => {
const artistsResponse = await getTopArtists().catch((err) => {
return NextResponse.json({ recently_played: false, message: 'Are you connected?', extra: err });
});

const tracksResponse = await getTopTracks().catch(err => {
const tracksResponse = await getTopTracks().catch((err) => {
return NextResponse.json({ recently_played: false, message: 'Are you connected?', extra: err });
});

Expand All @@ -29,6 +29,6 @@ export async function GET() {

return NextResponse.json({
artists: artists.map(normalizeArtists),
tracks: tracks.map(normalizeTracks)
tracks: tracks.map(normalizeTracks),
});
}
12 changes: 6 additions & 6 deletions app/blog/[slug]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function generateMetadata({ params }) {
const { frontMatter } = await fetchArticle({ slug });

const baseUrl = new URL(config.baseUrl);
const imagePath = frontMatter.image.startsWith('/') ? frontMatter.image : '/' + frontMatter.image;
const imagePath = frontMatter.image.startsWith('/') ? frontMatter.image : `/${frontMatter.image}`;
const imageUrl = new URL(imagePath, baseUrl).toString();

const dynamicMetadata = {
Expand All @@ -35,15 +35,15 @@ export async function generateMetadata({ params }) {
authors: [frontMatter.author.name],
tags: frontMatter.tags,
publishedTime: frontMatter.date,
modifiedTime: frontMatter.date
modifiedTime: frontMatter.date,
},
images: [
{
url: imageUrl,
alt: frontMatter.title
}
]
}
alt: frontMatter.title,
},
],
},
};
return dynamicMetadata;
}
Expand Down
8 changes: 3 additions & 5 deletions app/blog/authors/[author]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ export async function generateMetadata({ params }) {
const { author } = params;

return {
title: `> blog - ${author}`
title: `> blog - ${author}`,
};
}

export default async function BlogAuthor({ params }) {
const { author } = params;

const articles = (await getAllArticles()).filter(
article => kebapCase(article.author.name) === author
);
const articles = (await getAllArticles()).filter((article) => kebapCase(article.author.name) === author);

return (
<>
Expand All @@ -28,7 +26,7 @@ export default async function BlogAuthor({ params }) {

<div className={s.root}>
<div className="container">
{articles.map(article => (
{articles.map((article) => (
<ArticlePreview key={article.slug} {...article} />
))}
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/blog/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import meta from 'lib/config/metadata.js';
export const metadata = {
title: '> blog',
description: `Articles written with ❤️ by ${meta.author.name} and the Community. ${meta.description}`,
keywords: [...meta.keywords, 'blog', 'articles']
keywords: [...meta.keywords, 'blog', 'articles'],
};

export default async function Blog() {
Expand All @@ -20,7 +20,7 @@ export default async function Blog() {

<div className={s.root}>
<div className="container">
{articles.map(article => (
{articles.map((article) => (
<ArticlePreview key={article.slug} {...article} />
))}
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/blog/tags/[tag]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export async function generateMetadata({ params }) {
const { tag } = params;

return {
title: `> blog - ${tag}`
title: `> blog - ${tag}`,
};
}

export default async function BlogTag({ params }) {
const { tag } = params;

const articles = (await getAllArticles()).filter(article => {
return article.tags.map(tag => kebapCase(tag)).includes(tag);
const articles = (await getAllArticles()).filter((article) => {
return article.tags.map((tag) => kebapCase(tag)).includes(tag);
});

return (
Expand All @@ -27,7 +27,7 @@ export default async function BlogTag({ params }) {

<div className={s.root}>
<div className="container">
{articles.map(article => (
{articles.map((article) => (
<ArticlePreview key={article.slug} {...article} />
))}
</div>
Expand Down
4 changes: 3 additions & 1 deletion app/error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default function Eror({ error, reset }) {
<div className={s.root}>
<h2 className="title">Error unexpected. Can you fix me?</h2>

<button onClick={() => reset()}>Try again</button>
<button type="button" onClick={() => reset()}>
Try again
</button>
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion app/loading.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function Loading() {
return (
<div className="flex items-center justify-center h-screen">
<div className="w-32 h-32 border-b-2 border-gray-300 rounded-full animate-spin"></div>
<div className="w-32 h-32 border-b-2 border-gray-300 rounded-full animate-spin" />
</div>
);
}
12 changes: 6 additions & 6 deletions app/open-source/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const metadata = {
other: [
{
name: 'followers',
content: 'https://api.github.com/users/mateonunez/followers'
}
]
content: 'https://api.github.com/users/mateonunez/followers',
},
],
};

export default async function OpenSourcePage() {
Expand All @@ -24,9 +24,9 @@ export default async function OpenSourcePage() {
const profile = await profileFetcher();
const { sponsors = [], followers = [] } = profile;

delete profile['repositories'];
delete profile['followers'];
delete profile['sponsors'];
profile.repositories = undefined;
profile.followers = undefined;
profile.sponsors = undefined;

return (
<>
Expand Down
16 changes: 8 additions & 8 deletions app/sitemap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ function generateArticlesSitemap() {
const result = [];
const articleSlugs = fs
.readdirSync(path.join(process.cwd(), './articles'))
.filter(file => /\.mdx?$/.test(file))
.map(file => file.replace(/\.mdx?$/, ''));
.filter((file) => /\.mdx?$/.test(file))
.map((file) => file.replace(/\.mdx?$/, ''));

for (const slug of articleSlugs) {
result.push({
url: new URL(`/blog/${slug}`, config.baseUrl).toString(),
lastModified: new Date()
lastModified: new Date(),
});
}

Expand All @@ -25,20 +25,20 @@ export default function sitemap() {
return [
{
url: new URL('/', config.baseUrl).toString(),
lastModified: new Date()
lastModified: new Date(),
},
{
url: new URL('/blog', config.baseUrl).toString(),
lastModified: new Date()
lastModified: new Date(),
},
...articles,
{
url: new URL('/open-source', config.baseUrl).toString(),
lastModified: new Date()
lastModified: new Date(),
},
{
url: new URL('/spotify', config.baseUrl).toString(),
lastModified: new Date()
}
lastModified: new Date(),
},
];
}
2 changes: 1 addition & 1 deletion app/spotify/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import meta from 'lib/config/metadata.js';
export const metadata = {
title: '> spotify',
description: `Music that I love. ${meta.description}`,
keywords: [...meta.keywords, 'spotify', 'music', 'recently played', 'top']
keywords: [...meta.keywords, 'spotify', 'music', 'recently played', 'top'],
};

export default async function SpotifyPage() {
Expand Down
34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"all": true
},
"correctness": {
"all": true,
"useExhaustiveDependencies": "off"
}
},
"ignore": [".next/", "node_modules/", "./**/*.json"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120,
"ignore": [".next/", "node_modules/"]
},
"javascript": {
"formatter": {
"semicolons": "always",
"quoteStyle": "single"
}
}
}
Loading

0 comments on commit 18bbed4

Please sign in to comment.