feat: regularize front-matter, add new-post command

This commit is contained in:
saicaca
2023-10-18 17:31:11 +08:00
parent ad67a86ef9
commit 767d351bd5
15 changed files with 95 additions and 43 deletions

View File

@@ -6,11 +6,11 @@ import I18nKey from "../i18n/i18nKey";
interface Props {
class: string;
pubDate: Date;
published: Date;
tags: string[];
categories: string[];
}
const {pubDate, tags, categories} = Astro.props;
const {published, tags, categories} = Astro.props;
const className = Astro.props.class;
---
@@ -21,7 +21,7 @@ const className = Astro.props.class;
>
<Icon name="material-symbols:calendar-today-outline-rounded" class="text-xl"></Icon>
</div>
<span class="text-black/50 dark:text-white/50 text-sm font-medium">{formatDateToYYYYMMDD(pubDate)}</span>
<span class="text-black/50 dark:text-white/50 text-sm font-medium">{formatDateToYYYYMMDD(published)}</span>
</div>
<!-- categories -->
@@ -31,7 +31,7 @@ const className = Astro.props.class;
<Icon name="material-symbols:menu-rounded" class="text-xl"></Icon>
</div>
<div class="flex flex-row flex-nowrap">
{categories && categories.map(category => <div
{(categories && categories.length > 0) && categories.map(category => <div
class="with-divider"
>
<a href=`/archive/category/${category}`
@@ -40,7 +40,7 @@ const className = Astro.props.class;
{category}
</a>
</div>)}
{!categories && <div class="transition text-black/50 dark:text-white/50 text-sm font-medium">{i18n(I18nKey.uncategorized)}</div>}
{!(categories && categories.length > 0) && <div class="transition text-black/50 dark:text-white/50 text-sm font-medium">{i18n(I18nKey.uncategorized)}</div>}
</div>
</div>
@@ -51,7 +51,7 @@ const className = Astro.props.class;
<Icon name="material-symbols:tag-rounded" class="text-xl"></Icon>
</div>
<div class="flex flex-row flex-nowrap">
{tags && tags.map(tag => <div
{(tags && tags.length > 0) && tags.map(tag => <div
class="with-divider"
>
<a href=`/archive/tag/${tag}`
@@ -60,7 +60,7 @@ const className = Astro.props.class;
{tag}
</a>
</div>)}
{!tags && <div class="transition text-black/50 dark:text-white/50 text-sm font-medium">{i18n(I18nKey.noTags)}</div>}
{!(tags && tags.length > 0) && <div class="transition text-black/50 dark:text-white/50 text-sm font-medium">{i18n(I18nKey.noTags)}</div>}
</div>
</div>
</div>