mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
refactor: update datetime prop type to string and date
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export interface Props {
|
export interface Props {
|
||||||
datetime: string;
|
datetime: string | Date;
|
||||||
size?: "sm" | "lg";
|
size?: "sm" | "lg";
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ export default function Datetime({ datetime, size = "sm", className }: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormattedDatetime = ({ datetime }: { datetime: string }) => {
|
const FormattedDatetime = ({ datetime }: { datetime: string | Date }) => {
|
||||||
const myDatetime = new Date(datetime);
|
const myDatetime = new Date(datetime);
|
||||||
|
|
||||||
const date = myDatetime.toLocaleDateString([], {
|
const date = myDatetime.toLocaleDateString([], {
|
||||||
|
|||||||
Reference in New Issue
Block a user