-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): refine AlertCard (#216)
- Loading branch information
1 parent
a973f04
commit 65f99ae
Showing
1 changed file
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import dayjs from "dayjs"; | ||
import Dayjs from "dayjs"; | ||
|
||
// TODO: support expiration time | ||
export default function (props: { | ||
updatedAt: Date; | ||
createdAt: Date; | ||
showExpirationReminder: boolean; | ||
showExpirationReminder?: boolean; | ||
expirationDays?: number; | ||
}) { | ||
if (!props.showExpirationReminder) return null; | ||
const today = dayjs(); | ||
const diff = today.diff(props.createdAt, "days"); | ||
if (diff > 30) { | ||
return ( | ||
<div className="warning-card text-gray-600 dark:text-dark"> | ||
<div> | ||
请注意,本文编写于 {diff} 天前,最后修改于{" "} | ||
{today.diff(props.updatedAt, "days")} 天前,其中某些信息可能已经过时。 | ||
if (props.showExpirationReminder) { | ||
const dayjs = Dayjs(); | ||
const diff = dayjs.diff(props.createdAt, "days"); | ||
|
||
if (diff > (props.expirationDays || 30)) { | ||
return ( | ||
<div className="warning-card text-gray-600 dark:text-dark"> | ||
<div> | ||
请注意,本文编写于 {diff} 天前,最后修改于{" "} | ||
{dayjs.diff(props.updatedAt, "days")}{" "} | ||
天前,其中某些信息可能已经过时。 | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
} | ||
} | ||
|
||
return null; | ||
} |