The Node.js® Website
at main 1.2 kB view raw
1import { useFormatter } from 'next-intl'; 2import type { FC } from 'react'; 3 4import MetaBar from '@/components/Containers/MetaBar'; 5import GitHub from '@/components/Icons/Social/GitHub'; 6import Link from '@/components/Link'; 7import { useClientContext } from '@/hooks/server'; 8import { DEFAULT_DATE_FORMAT } from '@/next.calendar.constants.mjs'; 9import { getGitHubBlobUrl } from '@/util/gitHubUtils'; 10 11const WithMetaBar: FC = () => { 12 const { headings, readingTime, frontmatter, filename } = useClientContext(); 13 const formatter = useFormatter(); 14 15 const lastUpdated = frontmatter.date 16 ? formatter.dateTime(new Date(frontmatter.date), DEFAULT_DATE_FORMAT) 17 : undefined; 18 19 return ( 20 <MetaBar 21 items={{ 22 'components.metabar.lastUpdated': lastUpdated, 23 'components.metabar.readingTime': readingTime.text, 24 'components.metabar.contribute': ( 25 <> 26 <GitHub className="fill-neutral-700 dark:fill-neutral-100" /> 27 <Link href={getGitHubBlobUrl(filename)}>Edit this page</Link> 28 </> 29 ), 30 }} 31 headings={{ items: headings }} 32 /> 33 ); 34}; 35 36export default WithMetaBar;