/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React from 'react'; import classnames from 'classnames'; import {MDXProvider} from '@mdx-js/react'; import Link from '@docusaurus/Link'; import MDXComponents from '@theme/MDXComponents'; import styles from './styles.module.css'; const MONTHS = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ]; function BlogPostItem(props) { const { children, frontMatter, metadata, truncated, isBlogPostPage = false, } = props; const {date, permalink, tags} = metadata; const {author, title} = frontMatter; const authorURL = frontMatter.author_url || frontMatter.authorURL; const authorTitle = frontMatter.author_title || frontMatter.authorTitle; const authorImageURL = frontMatter.author_image_url || frontMatter.authorImageURL; const renderPostHeader = () => { const TitleHeading = isBlogPostPage ? 'h1' : 'h2'; const match = date.substring(0, 10).split('-'); const year = match[0]; const month = MONTHS[parseInt(match[1], 10) - 1]; const day = parseInt(match[2], 10); return ( {isBlogPostPage ? title : {title}} {month} {day}, {year} {authorImageURL && ( )} {author && ( <> {author} {authorTitle} > )} ); }; return ( {renderPostHeader()} {children} {(tags.length > 0 || truncated) && ( )} ); } export default BlogPostItem;