mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 23:02:53 +01:00
feat: regularize front-matter, add new-post command
This commit is contained in:
@@ -26,7 +26,7 @@ if (Array.isArray(categories) && categories.length > 0) {
|
||||
|
||||
const groups = function () {
|
||||
const groupedPosts = posts.reduce((grouped, post) => {
|
||||
const year = post.data.pubDate.getFullYear()
|
||||
const year = post.data.published.getFullYear()
|
||||
if (!grouped[year]) {
|
||||
grouped[year] = []
|
||||
}
|
||||
@@ -73,7 +73,7 @@ function formatDate(date: Date) {
|
||||
<Button light height="40px" class="w-full rounded-lg hover:text-[initial]">
|
||||
<div class="flex flex-row justify-start items-center h-full">
|
||||
<!-- date -->
|
||||
<div class="w-[10%] transition text-sm text-right text-black/50 dark:text-white/50">{formatDate(post.data.pubDate)}</div>
|
||||
<div class="w-[10%] transition text-sm text-right text-black/50 dark:text-white/50">{formatDate(post.data.published)}</div>
|
||||
<!-- dot and line -->
|
||||
<div class="w-[10%] relative dash-line h-full flex items-center">
|
||||
<div class="transition-all mx-auto w-1 h-1 rounded group-hover:h-5
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -3,13 +3,13 @@ import {formatDateToYYYYMMDD} from "../utils/date-utils";
|
||||
interface Props {
|
||||
title: string;
|
||||
url: string;
|
||||
pubDate: Date;
|
||||
published: Date;
|
||||
tags: string[];
|
||||
cover: string;
|
||||
description: string;
|
||||
words: number;
|
||||
}
|
||||
const { title, url, pubDate, tags, cover, description, words } = Astro.props;
|
||||
const { title, url, published, tags, cover, description, words } = Astro.props;
|
||||
// console.log(Astro.props);
|
||||
import ImageBox from "./misc/ImageBox.astro";
|
||||
import ButtonTag from "./control/ButtonTag.astro";
|
||||
@@ -40,7 +40,7 @@ const hasCover = cover !== undefined && cover !== null && cover !== '';
|
||||
This is a very long title
|
||||
</a>
|
||||
<div class="flex text-neutral-500 dark:text-neutral-400 items-center mb-1">
|
||||
<div>{formatDateToYYYYMMDD(pubDate)}</div>
|
||||
<div>{formatDateToYYYYMMDD(published)}</div>
|
||||
<div class="transition h-1 w-1 rounded-sm bg-neutral-400 dark:bg-neutral-600 mx-3"></div>
|
||||
<div>Uncategorized</div>
|
||||
<div class="transition h-1 w-1 rounded-sm bg-neutral-400 dark:bg-neutral-600 mx-3"></div>
|
||||
|
||||
@@ -5,14 +5,14 @@ interface Props {
|
||||
entry: any;
|
||||
title: string;
|
||||
url: string;
|
||||
pubDate: Date;
|
||||
published: Date;
|
||||
tags: string[];
|
||||
categories: string[];
|
||||
cover: string;
|
||||
description: string;
|
||||
words: number;
|
||||
}
|
||||
const { entry, title, url, pubDate, tags, categories, cover, description, words } = Astro.props;
|
||||
const { entry, title, url, published, tags, categories, cover, description, words } = Astro.props;
|
||||
const className = Astro.props.class;
|
||||
// console.log(Astro.props);
|
||||
import ImageBox from "./misc/ImageBox.astro";
|
||||
@@ -46,7 +46,7 @@ const { remarkPluginFrontmatter } = await entry.render();
|
||||
</a>
|
||||
|
||||
<!-- metadata -->
|
||||
<PostMetadata pubDate={pubDate} tags={tags} categories={categories} class:list={{"mb-4": description, "mb-6": !description}}></PostMetadata>
|
||||
<PostMetadata published={published} tags={tags} categories={categories} class:list={{"mb-4": description, "mb-6": !description}}></PostMetadata>
|
||||
|
||||
<div class="transition text-black/75 dark:text-white/75 mb-4">
|
||||
{ description }
|
||||
|
||||
Reference in New Issue
Block a user