mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
refactor: update component props and improve types (#600)
- stop exporting component Props - replace interface with type for component Props - enhance dynamic rendering in several components
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
---
|
||||
import type { MarkdownLayoutProps } from "astro";
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
import Breadcrumb from "@/components/Breadcrumb.astro";
|
||||
import Layout from "./Layout.astro";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
export interface Props {
|
||||
frontmatter: {
|
||||
title: string;
|
||||
description?: string;
|
||||
};
|
||||
}
|
||||
type Props = MarkdownLayoutProps<{ title: string }>;
|
||||
|
||||
const { frontmatter } = Astro.props;
|
||||
---
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PUBLIC_GOOGLE_SITE_VERIFICATION } from "astro:env/client";
|
||||
import { SITE } from "@/config";
|
||||
import "@/styles/global.css";
|
||||
|
||||
export interface Props {
|
||||
type Props = {
|
||||
title?: string;
|
||||
author?: string;
|
||||
profile?: string;
|
||||
@@ -14,7 +14,7 @@ export interface Props {
|
||||
pubDatetime?: Date;
|
||||
modDatetime?: Date | null;
|
||||
scrollSmooth?: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
const {
|
||||
title = SITE.title,
|
||||
|
||||
+3
-11
@@ -2,18 +2,10 @@
|
||||
import Breadcrumb from "@/components/Breadcrumb.astro";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
interface StringTitleProp {
|
||||
pageTitle: string;
|
||||
pageDesc?: string;
|
||||
}
|
||||
type StringTitle = { pageTitle: string };
|
||||
type ArrayTitle = { pageTitle: [string, string]; titleTransition: string };
|
||||
|
||||
interface ArrayTitleProp {
|
||||
pageTitle: [string, string];
|
||||
titleTransition: string;
|
||||
pageDesc?: string;
|
||||
}
|
||||
|
||||
export type Props = StringTitleProp | ArrayTitleProp;
|
||||
type Props = (StringTitle | ArrayTitle) & { pageDesc?: string };
|
||||
|
||||
const { props } = Astro;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user