-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor post components and move to astro
- Loading branch information
Showing
9 changed files
with
138 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
import { SITE_LANG } from '@constant/app' | ||
type Props = { | ||
date: Date | ||
} | ||
const { date } = Astro.props | ||
--- | ||
|
||
<time datetime={date.toISOString()}> | ||
{ | ||
date.toLocaleDateString(SITE_LANG, { | ||
year: 'numeric', | ||
month: 'short', | ||
day: 'numeric', | ||
}) | ||
} | ||
</time> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
import type { BlogEntry } from '@content/config' | ||
import FormattedDate from './FormattedDate.astro' | ||
type Props = { | ||
post: BlogEntry | ||
showPin?: boolean | ||
} | ||
const { post, showPin } = Astro.props | ||
const isPin = post.data.pin | ||
const date = post.data.date || (post.data.pubDate as Date) | ||
--- | ||
|
||
<article | ||
class={`m-4 rounded-md border border-transparent p-4 hover:border-gray-300 transition-[border] duration-200 ${showPin && isPin && 'bg-main/5 dark:bg-main/15'}`} | ||
aria-label={`Article: ${post.data.title}`} | ||
> | ||
<div class="flex items-center text-sm uppercase text-gray-500"> | ||
<FormattedDate date={date} /> | ||
{ | ||
post.data.category && ( | ||
<a | ||
href={`/archive/categories/${post.data.category}`} | ||
class="relative ml-2 pl-1 text-main before:absolute before:-left-1 before:top-1/2 before:h-0.5 before:w-0.5 before:-translate-y-1/2 before:rounded-full before:bg-gray-500 hover:underline" | ||
aria-label={`Link to ${post.data.category} category page`} | ||
> | ||
{post.data.category} | ||
</a> | ||
) | ||
} | ||
</div> | ||
<a href={`/posts/${post.slug}/`}> | ||
<h2 | ||
class="my-2 line-clamp-2 text-4xl font-bold uppercase tracking-wide dark:text-gray-400" | ||
aria-label={post.data.title} | ||
> | ||
{post.data.title} | ||
</h2> | ||
{ | ||
post.data.description && ( | ||
<p class="text-gray-500" aria-label={post.data.description}> | ||
{post.data.description} | ||
</p> | ||
) | ||
} | ||
</a> | ||
</article> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
import type { PostMeta } from '@model/post-meta' | ||
import { convertDash } from 'src/util/convertDash' | ||
import FormattedDate from './FormattedDate.astro' | ||
type Props = { | ||
meta: PostMeta | ||
} | ||
const { meta } = Astro.props | ||
--- | ||
|
||
<div class="flex flex-col"> | ||
<div class="mx-1 flex items-center text-sm text-gray-400"> | ||
<FormattedDate date={meta.updatedDate || meta.date} /> | ||
{ | ||
meta.category && ( | ||
<a | ||
href={`/archive/categories/${meta.category}`} | ||
class="dot relative uppercase text-main hover:underline" | ||
aria-label={`Link to ${meta.category} category page`} | ||
> | ||
{meta.category} | ||
</a> | ||
) | ||
} | ||
{ | ||
meta.readingTime && ( | ||
<div class="dot relative">{Math.ceil(meta.readingTime.minutes)} mins read</div> | ||
) | ||
} | ||
</div> | ||
<div class="flex justify-between"> | ||
<div class="flex flex-1 flex-col"> | ||
<div class="mb-8 pt-1"> | ||
<h1 class="text-7xl font-bold uppercase" aria-label="Post title"> | ||
{meta.title} | ||
</h1> | ||
{ | ||
meta.subTitle && ( | ||
<div class="flex justify-end pt-4"> | ||
<h1 class="text-3xl text-gray-400" aria-label="Post subtitle"> | ||
—— {meta.subTitle} | ||
</h1> | ||
</div> | ||
) | ||
} | ||
</div> | ||
</div> | ||
<div> | ||
{ | ||
meta.tags?.map(tag => ( | ||
<a href={`/tags/${convertDash(tag)}`} class="rounded-sm text-main hover:animate-flashBtn"> | ||
{tag} | ||
</a> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.dot { | ||
@apply ml-2 pl-1 before:absolute before:-left-1 before:top-1/2 before:h-0.5 before:w-0.5 before:-translate-y-1/2 before:rounded-full before:bg-gray-500; | ||
} | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters