Skip to content

Commit

Permalink
style: apply Biome formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
junkisai committed Oct 3, 2024
1 parent 3867c14 commit f0da17d
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 117 deletions.
8 changes: 4 additions & 4 deletions frontend/apps/service-site/contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineDocumentType, makeSource } from 'contentlayer/source-files'

export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: `posts/*.md`,
filePathPattern: 'posts/*.md',
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
Expand All @@ -27,10 +27,10 @@ export const Post = defineDocumentType(() => ({
computedFields: {
href: { type: 'string', resolve: (post) => `/${post._raw.flattenedPath}` },
slug: {
type: "string",
type: 'string',
resolve: (post) => {
const segments = post._raw.flattenedPath.split("/");
return segments[segments.length - 1];
const segments = post._raw.flattenedPath.split('/')
return segments[segments.length - 1]
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions frontend/apps/service-site/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withContentlayer } from 'next-contentlayer';
import { withContentlayer } from 'next-contentlayer'
/** @type {import('next').NextConfig} */
const nextConfig = { reactStrictMode: true, images: { domains: ['localhost'] } };
export default withContentlayer(nextConfig)
const nextConfig = { reactStrictMode: true, images: { domains: ['localhost'] } }
export default withContentlayer(nextConfig)
2 changes: 1 addition & 1 deletion frontend/apps/service-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:biome": "biome check .",
"lint:next": "next lint",
"fmt": "conc -c auto pnpm:fmt:*",
"fmt:biome": "biome format --write ."
"fmt:biome": "biome check --write --unsafe ."
},
"dependencies": {
"contentlayer": "^0.3.4",
Expand Down
25 changes: 12 additions & 13 deletions frontend/apps/service-site/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import type { Metadata } from "next";
import "../styles/globals.css";
import { Header, Footer } from "../components";
import type { Metadata } from 'next'
import '@/styles/globals.css'
import { Footer, Header } from '@/components'
import type { ReactNode } from 'react'

export const metadata: Metadata = {
title: "Liam",
description: "Liam blog",
};
title: 'Liam',
description: 'Liam blog',
}

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
children: ReactNode
}>) {
return (
<html lang="en">
<body>
<Header></Header>
<main>
{children}
</main>
<Footer></Footer>
<Header />
<main>{children}</main>
<Footer />
</body>
</html>
);
)
}
12 changes: 6 additions & 6 deletions frontend/apps/service-site/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { compareDesc } from 'date-fns'
import { allPosts } from 'contentlayer/generated'
import { TopCards } from '../components/TopCards'
import { compareDesc } from 'date-fns'
import { TopCards } from '../components'

export default function Home() {
const posts = allPosts.sort((a, b) => compareDesc(new Date(a.date), new Date(b.date)))

return (
<TopCards posts={posts.slice(0, 14)}/>
const posts = allPosts.sort((a, b) =>
compareDesc(new Date(a.date), new Date(b.date)),
)

return <TopCards posts={posts.slice(0, 14)} />
}
14 changes: 8 additions & 6 deletions frontend/apps/service-site/src/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { format, parseISO } from 'date-fns'
import { allPosts } from 'contentlayer/generated'
import { format, parseISO } from 'date-fns'

export const getPost = (slug: string) => {
return allPosts.find((post) => post.href === slug);
};
return allPosts.find((post) => post.href === slug)
}

export const generateStaticParams = async () => allPosts.map((post) => ({ slug: post._raw.flattenedPath }))
export const generateStaticParams = async () =>
allPosts.map((post) => ({ slug: post._raw.flattenedPath }))

export const generateMetadata = ({ params }: { params: { slug: string } }) => {
const post = getPost(`/posts/${params.slug}`);
const post = getPost(`/posts/${params.slug}`)
if (!post) throw new Error(`Post not found for slug: ${params.slug}`)
return { title: post.title }
}

const PostLayout = ({ params }: { params: { slug: string } }) => {
const post = getPost(`/posts/${params.slug}`);
const post = getPost(`/posts/${params.slug}`)
if (!post) throw new Error(`Post not found for slug: ${params.slug}`)
return (
<article>
Expand All @@ -24,6 +25,7 @@ const PostLayout = ({ params }: { params: { slug: string } }) => {
</time>
<h1>{post.title}</h1>
</div>
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation> */}
<div dangerouslySetInnerHTML={{ __html: post.body.html }} />
</article>
)
Expand Down
17 changes: 9 additions & 8 deletions frontend/apps/service-site/src/app/posts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import Link from 'next/link'
import { type Post, allPosts } from 'contentlayer/generated'
import { compareDesc, format, parseISO } from 'date-fns'
import { allPosts, Post } from 'contentlayer/generated'
import Link from 'next/link'

function PostCard(post: Post) {
return (
<div>
<h2>
<Link href={post.href}>
{post.title}
</Link>
<Link href={post.href}>{post.title}</Link>
</h2>
<time dateTime={post.date}>
{format(parseISO(post.date), 'LLLL d, yyyy')}
</time>
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation> */}
<div dangerouslySetInnerHTML={{ __html: post.body.html }} />
</div>
)
}

export default function Home() {
const posts = allPosts.sort((a, b) => compareDesc(new Date(a.date), new Date(b.date)))
const posts = allPosts.sort((a, b) =>
compareDesc(new Date(a.date), new Date(b.date)),
)

return (
<div>
<h1>Posts</h1>
{posts.map((post, idx) => (
<PostCard key={idx} {...post} />
{posts.map((post) => (
<PostCard key={post.slug} {...post} />
))}
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions frontend/apps/service-site/src/components/Footer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
font-style: normal;
font-weight: 400;
line-height: normal;
transition: color var(--default-hover-animation-duration) var(--default-timing-function);
transition: color var(--default-hover-animation-duration)
var(--default-timing-function);
padding: var(--spacing-2, 8px);

&:hover {
Expand All @@ -48,7 +49,8 @@
.snsLink {
& path {
fill: var(--overlay-70);
transition: fill var(--default-hover-animation-duration) var(--default-timing-function);
transition: fill var(--default-hover-animation-duration)
var(--default-timing-function);
}

&:hover path {
Expand Down
27 changes: 16 additions & 11 deletions frontend/apps/service-site/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Link from 'next/link';
import styles from './Footer.module.css';
import { LiamLogoMark, Github, X } from './logos';

import Link from 'next/link'
import styles from './Footer.module.css'
import { Github, LiamLogoMark, X } from './logos'

export const Footer = () => {
return (
Expand All @@ -10,22 +9,28 @@ export const Footer = () => {
<Link href="/" className={styles.logo}>
<LiamLogoMark />
</Link>
<p className={styles.text}>
&copy; 2024 Liam
</p>
<p className={styles.text}>&copy; 2024 Liam</p>
</div>
<div className={styles.linksContainer}>
<Link href="/" className={styles.textLink}>
{/* TODO: Add Privacy Policy link */}
Privacy Policy
</Link>
<Link href="https://github.com/route06inc/liam" className={styles.snsLink} target="_blank">
<Link
href="https://github.com/route06inc/liam"
className={styles.snsLink}
target="_blank"
>
<Github />
</Link>
<Link href="https://x.com/liam_app" className={styles.snsLink} target="_blank">
<Link
href="https://x.com/liam_app"
className={styles.snsLink}
target="_blank"
>
<X />
</Link>
</div>
</footer>
);
};
)
}
22 changes: 11 additions & 11 deletions frontend/apps/service-site/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Link from 'next/link'
import styles from './Header.module.css'
import { LiamLogo } from './logos'
import styles from './Header.module.css';

export const Header = () => {
return (
<header className={styles.header}>
<Link href="/">
<h1 className={styles.h1}>
<LiamLogo />
</h1>
</Link>
</header>
);
};
return (
<header className={styles.header}>
<Link href="/">
<h1 className={styles.h1}>
<LiamLogo />
</h1>
</Link>
</header>
)
}
13 changes: 4 additions & 9 deletions frontend/apps/service-site/src/components/TopCards.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
.title {
font-size: var(--font-size-10, 24px);
font-weight: 400;
line-height: 120%;
line-height: 120%;
font-family: var(--message-font);
}

Expand All @@ -71,7 +71,6 @@
}

.topCards > :not(:first-child):not(:nth-child(2)) {

.title {
line-clamp: 4;
-webkit-line-clamp: 4;
Expand All @@ -84,7 +83,6 @@

.topCards > :first-child,
.topCards > :nth-child(2) {

.textContainer {
margin: var(--spacing-20, 80px) 0;
justify-content: flex-start;
Expand All @@ -105,7 +103,7 @@
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
height: auto
height: auto;
}

.introduction {
Expand Down Expand Up @@ -142,23 +140,20 @@
}

.topCards > :first-child {

.topCard {
padding-left: 0;
margin-left: calc(-1 * var(--spacing-20, 80px));
margin-left: calc(-1 * var(--spacing-20, 80px));
}

.textContainer {
padding-left: var(--spacing-20, 80px);
}
}


.topCards > :nth-child(2) {

.topCard {
padding-right: 0;
margin-right: - var(--spacing-20, 80px);
margin-right: calc(-1 * var(--spacing-20, 80px));
}

.textContainer {
Expand Down
28 changes: 12 additions & 16 deletions frontend/apps/service-site/src/components/TopCards.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Post } from "@/.contentlayer/generated";
import Link from "next/link";
import Image from "next/image";
import styles from "./TopCards.module.css";
import type { Post } from 'contentlayer/generated'
import Image from 'next/image'
import Link from 'next/link'
import styles from './TopCards.module.css'
interface TopCardsProps {
posts: Post[];
posts: Post[]
}

export function TopCards({ posts }: TopCardsProps) {
Expand All @@ -27,22 +27,18 @@ export function TopCards({ posts }: TopCardsProps) {
<div className={styles.textContainer}>
<div className={styles.tags}>
{post.tags.map((tag) => (
<span key={tag} className={styles.tag}>( {tag} )</span>
<span key={tag} className={styles.tag}>
( {tag} )
</span>
))}
</div>
<h2 className={styles.title}>
{post.title}
</h2>
<p className={styles.writer}>
Text by {post.writer}
</p>
<div className={styles.introduction}>
{post.introduction}
</div>
<h2 className={styles.title}>{post.title}</h2>
<p className={styles.writer}>Text by {post.writer}</p>
<div className={styles.introduction}>{post.introduction}</div>
</div>
</div>
</Link>
))}
</div>
);
)
}
5 changes: 3 additions & 2 deletions frontend/apps/service-site/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { Header } from "./Header";
export { Footer } from "./Footer";
export { Header } from './Header'
export { Footer } from './Footer'
export * from './TopCards'
Loading

0 comments on commit f0da17d

Please sign in to comment.