Skip to content

Commit

Permalink
feat(ui): create /blog/til page
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Nov 28, 2023
1 parent 97698f4 commit ef0f4a5
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/app/blog/til/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { allTILs, TIL } from 'contentlayer/generated'
import { useMDXComponent } from 'next-contentlayer/hooks'

import { Title } from '@/shared/components/title'
import { Date } from '@/shared/components/date'

import 'katex/dist/katex.min.css'

const TILComponent = ({ til }: { til: TIL }) => {
const MDXContent = useMDXComponent(til.body.code)
return (
<div className="relative flex flex-col gap-6 border-b border-b-neutral-200 py-12 last:border-none dark:border-b-neutral-800 md:flex-row md:gap-1">
<div className="top-24 h-fit w-full space-y-2 md:sticky md:space-y-5">
<div className="space-y-3">
<h2 className="text-xl font-bold">{til.title}</h2>
<p>{til.description}</p>
<span className="text-sm">
<Date dateString={til.date} />
</span>
</div>
<div className="flex flex-wrap gap-1">
{til.tags.map(tag => (
<span
className="rounded-lg bg-neutral-400/10 p-1 text-sm leading-none"
key={tag}
>
{tag}
</span>
))}
</div>
</div>
<div className="post-content til-content md:w-2/3">
<MDXContent />
</div>
</div>
)
}

export default function Page() {
return (
<div className="content-container m-auto space-y-4">
<Title text="Today I Learned" />
<div className="flex flex-col gap-3">
{allTILs.map(til => (
<TILComponent til={til} key={til.date} />
))}
</div>
</div>
)
}
37 changes: 37 additions & 0 deletions src/styles/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,41 @@
}
}
}

.til-content {
nav {
&.toc {
@apply hidden;
}
}

h1,
h2,
h3,
h4,
h5,
h6 {
@apply m-0;
}

h2 {
@apply pb-1 text-2xl underline-offset-2;
}
h3 {
@apply pb-0 text-xl underline-offset-2;
}
h4 {
@apply text-xl;
}
h5 {
@apply text-lg;
}
h6 {
@apply text-base;
}

p {
@apply my-4 border-red-600 last:mb-0 [&:nth-child(2)]:mt-0;
}
}
}

0 comments on commit ef0f4a5

Please sign in to comment.