mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
refactor: update frontmatter type and change React to Astro
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
import Datetime from "./Datetime";
|
||||||
|
import type { BlogFrontmatter } from "@content/schemas";
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
href?: string;
|
||||||
|
frontmatter: BlogFrontmatter;
|
||||||
|
secHeading?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { href, frontmatter, secHeading } = Astro.props;
|
||||||
|
|
||||||
|
const { title, publishDatetime, description } = frontmatter;
|
||||||
|
---
|
||||||
|
|
||||||
|
<li class="card-container">
|
||||||
|
<a href={href} class="card-link">
|
||||||
|
{
|
||||||
|
secHeading ? (
|
||||||
|
<h2 class="card-heading">{title}</h2>
|
||||||
|
) : (
|
||||||
|
<h3 class="card-heading">{title}</h3>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</a>
|
||||||
|
<Datetime datetime={publishDatetime} />
|
||||||
|
<p>{description}</p>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.card-container {
|
||||||
|
@apply my-6;
|
||||||
|
}
|
||||||
|
.card-link {
|
||||||
|
@apply text-skin-accent font-medium text-lg underline-offset-4 decoration-dashed focus-visible:no-underline focus-visible:underline-offset-0 inline-block;
|
||||||
|
}
|
||||||
|
.card-heading {
|
||||||
|
@apply font-medium text-lg decoration-dashed hover:underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import Datetime from "./Datetime";
|
|
||||||
import type { Frontmatter } from "src/types";
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
href?: string;
|
|
||||||
post: Frontmatter;
|
|
||||||
secHeading?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles = {
|
|
||||||
cardContainer: "my-6",
|
|
||||||
titleLink:
|
|
||||||
"text-skin-accent font-medium text-lg underline-offset-4 decoration-dashed focus-visible:no-underline focus-visible:underline-offset-0 inline-block",
|
|
||||||
titleHeading: "font-medium text-lg decoration-dashed hover:underline",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Card({ href, post, secHeading = true }: Props) {
|
|
||||||
return (
|
|
||||||
<li className={styles.cardContainer}>
|
|
||||||
<a href={href} className={styles.titleLink}>
|
|
||||||
{secHeading ? (
|
|
||||||
<h2 className={styles.titleHeading}>{post.title}</h2>
|
|
||||||
) : (
|
|
||||||
<h3 className={styles.titleHeading}>{post.title}</h3>
|
|
||||||
)}
|
|
||||||
</a>
|
|
||||||
<Datetime datetime={post.datetime} />
|
|
||||||
<p>{post.description}</p>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user