mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 12:07:00 +02:00
refactor(v2): blog data revamp (#1450)
* refactor(v2): blog data revamp * fix(v2): fix incorrect blog total count * misc: remove console.log * feat(v2): export frontMatter as an object within MDX file (#1451) * refactor. Don't confuse metadata & frontmatter * export frontMatter in content itself * nits * nits name * dont truncate first four lines in blog
This commit is contained in:
parent
070723697f
commit
23b50f17a1
18 changed files with 258 additions and 119 deletions
|
@ -9,20 +9,11 @@ import React from 'react';
|
|||
import Link from '@docusaurus/Link';
|
||||
|
||||
function BlogPostItem(props) {
|
||||
const {metadata, children, truncated} = props;
|
||||
const {children, frontMatter, metadata, truncated} = props;
|
||||
|
||||
const renderPostHeader = () => {
|
||||
if (!metadata) {
|
||||
return null;
|
||||
}
|
||||
const {
|
||||
date,
|
||||
author,
|
||||
authorURL,
|
||||
authorTitle,
|
||||
authorFBID,
|
||||
permalink,
|
||||
title,
|
||||
} = metadata;
|
||||
const {author, authorURL, authorTitle, authorFBID, title} = frontMatter;
|
||||
const {date, permalink} = metadata;
|
||||
|
||||
const blogPostDate = new Date(date);
|
||||
const month = [
|
||||
|
@ -39,9 +30,10 @@ function BlogPostItem(props) {
|
|||
'November',
|
||||
'December',
|
||||
];
|
||||
|
||||
const authorImageURL = authorFBID
|
||||
? `https://graph.facebook.com/${authorFBID}/picture/?height=200&width=200`
|
||||
: metadata.authorImageURL;
|
||||
: frontMatter.authorImageURL;
|
||||
|
||||
return (
|
||||
<header>
|
||||
|
@ -88,10 +80,8 @@ function BlogPostItem(props) {
|
|||
{renderPostHeader()}
|
||||
<article className="markdown">{children}</article>
|
||||
{truncated && (
|
||||
<div className="text--right">
|
||||
<Link className="button button--secondary" to={metadata.permalink}>
|
||||
Read More
|
||||
</Link>
|
||||
<div className="text--right margin-vert--md">
|
||||
<Link to={metadata.permalink}>Read More</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue