docs: move edit date to footer (#11667)
* docs: move edit date to footer * fix build error
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import React from "react"
|
||||
|
||||
const DATE_REGEX = /^[a-zA-Z]+ (?<month>[a-zA-Z]+)/
|
||||
|
||||
type EditDateProps = {
|
||||
date: string
|
||||
}
|
||||
|
||||
export const EditDate = ({ date }: EditDateProps) => {
|
||||
const today = new Date(date)
|
||||
const dateObj = new Date(date)
|
||||
const formattedDate = dateObj.toString()
|
||||
const dateMatch = DATE_REGEX.exec(formattedDate)
|
||||
|
||||
if (!dateMatch?.groups?.month) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<span className="text-compact-small-plus">
|
||||
Edited {dateMatch.groups.month} {dateObj.getDate()}
|
||||
{dateObj.getFullYear() !== today.getFullYear()
|
||||
? `, ${dateObj.getFullYear()}`
|
||||
: ""}
|
||||
</span>
|
||||
<span className="text-compact-small">·</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user