docs: move edit date to footer (#11667)

* docs: move edit date to footer

* fix build error
This commit is contained in:
Shahed Nasser
2025-02-28 16:27:42 +02:00
committed by GitHub
parent 228b7b608d
commit bf67f69f45
23 changed files with 183 additions and 121 deletions
@@ -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">&#183;</span>
</>
)
}