Skip to content

Commit

Permalink
feat: add dates to faq page
Browse files Browse the repository at this point in the history
  • Loading branch information
aliceoq committed Feb 9, 2024
1 parent 8f46090 commit 0cb240e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/pages/faq/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { useIntl } from 'react-intl'
import { remarkReadingTime } from 'utils/remark_plugins/remarkReadingTime'
import { getDocsPaths as getFaqPaths } from 'utils/getDocsPaths'
import { getMessages } from 'utils/get-messages'
import DateText from 'components/date-text'

const docsPathsGLOBAL = await getFaqPaths('faq')

Expand Down Expand Up @@ -71,6 +72,14 @@ const FaqPage: NextPage<Props> = ({
setHeadings(headingList)
}, [serialized.frontmatter])

const createdAtDate = serialized.frontmatter?.createdAt
? new Date(serialized.frontmatter?.createdAt)
: undefined

const updatedAtDate = serialized.frontmatter?.updatedAt
? new Date(serialized.frontmatter?.updatedAt)
: undefined

return (
<>
<Head>
Expand All @@ -92,8 +101,11 @@ const FaqPage: NextPage<Props> = ({
<Box sx={styles.contentContainer}>
<article ref={articleRef}>
<header>
<Breadcrumb breadcrumbList={breadcrumbList} />
<Flex sx={styles.flexContainer}>
<Breadcrumb breadcrumbList={breadcrumbList} />
<Text sx={styles.documentationTitle} className="title">
{serialized.frontmatter?.title}
</Text>
<Text sx={styles.readingTime}>
{intl.formatMessage(
{
Expand All @@ -103,11 +115,13 @@ const FaqPage: NextPage<Props> = ({
{ minutes: serialized.frontmatter?.readingTime }
)}
</Text>
{createdAtDate && updatedAtDate && (
<DateText
createdAt={createdAtDate}
updatedAt={updatedAtDate}
/>
)}
</Flex>
<Text sx={styles.documentationTitle} className="title">
{serialized.frontmatter?.title}
</Text>
<Box sx={styles.divider}></Box>
</header>
<MarkdownRenderer serialized={serialized} />
</article>
Expand Down

0 comments on commit 0cb240e

Please sign in to comment.