Files
medusa-store/www/packages/docs-ui/src/components/MainNav/EditDate/index.tsx
Shahed Nasser c63a08fb03 docs: second round of polishing (#8724)
* docs: second round of polishing

* fix overflowing width
2024-08-23 10:42:23 +03:00

31 lines
732 B
TypeScript

import React from "react"
const DATE_REGEX = /^[a-zA-Z]+ (?<month>[a-zA-Z]+)/
type MainNavEditDateProps = {
date: string
}
export const MainNavEditDate = ({ date }: MainNavEditDateProps) => {
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">
Edited {dateMatch.groups.month} {dateObj.getDate()}
{dateObj.getFullYear() !== today.getFullYear()
? `, ${dateObj.getFullYear()}`
: ""}
</span>
<span className="text-compact-small">&#183;</span>
</>
)
}