Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
reafctor(article): rename prop from post to article (close #171)
Browse files Browse the repository at this point in the history
In `article` component
  • Loading branch information
hitsuji_no_shippo committed Jan 28, 2020
1 parent 510ddbf commit 0bdb846
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
:author: {author-name}
:!email: {author-email}
:revnumber: Branch refactor/collect-codes-to-one-directory-and-update-prop-types \
v1.0.0 (Base v1.72.0)
:revdate: 2020-01-28T12:56:52+0900
:revremark: Add log that delete useless comments.
v1.1.0 (Base v1.72.0)
:revdate: 2020-01-28T12:59:58+0900
:revremark: Add log that \
rename prop from `post` to `article` in `article` component.
:doctype: article
:description: gatsby-simple-blog-with-asciidoctor Change Log
:title:
Expand Down Expand Up @@ -117,6 +118,8 @@ ifndef::env-github[:icons: font]
--
* Collect `LanguageBar` component codes. (close link:{issues-url}/155[#155^])
* Delete useless comments. (close link:{issues-url}/170[#170^])
* Rename prop from `post` to `article` in `article` component.
(close link:{issues-url}/171[#171^])

=== Docs

Expand Down
8 changes: 4 additions & 4 deletions src/components/Article/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import minimatch from 'minimatch';

import { repository, articles } from 'config'

const Footer = ({post}) => {
const Footer = ({article}) => {
if (!(articles.dir && articles.filePath
&& (repository.url || articles.isOtherRepositroy))) {
return null;
}

const filePath = (() => {
let value = post;
let value = article;

articles.filePath[post.internal.type].split('.').some(path => {
articles.filePath[article.internal.type].split('.').some(path => {
value = Object.prototype.hasOwnProperty.call(value, path)
? value[path]
: null;
Expand Down Expand Up @@ -52,7 +52,7 @@ const Footer = ({post}) => {
}

Footer.propTypes = {
post: PropTypes.object.isRequired,
article: PropTypes.object.isRequired,
};

export default Footer;
26 changes: 13 additions & 13 deletions src/components/Article/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { rhythm, scale } from 'utils/typography';
import TranslationsLink from './TranslationsLink';


const Header = ({post, slug, translationsLink, languageContexts}) => {
const Header = ({article, slug, translationsLink, languageContexts}) => {
return (
<header>
<h1>{post.document.title}</h1>
<h1>{article.document.title}</h1>
<p
style={{
...scale(-1 / 5),
Expand All @@ -22,24 +22,24 @@ const Header = ({post, slug, translationsLink, languageContexts}) => {
}}
>
<AccessoryInformations
dateStr={post.revision.date}
timeToRead={post.timeToRead}
dateStr={article.revision.date}
timeToRead={article.timeToRead}
disqus={{
id: post.id,
title: post.document.title,
id: article.id,
title: article.document.title,
slug,
show: post.pageAttributes.disqus !== false,
show: article.pageAttributes.disqus !== false,
}}
author={{
name: post.author.fullName,
url: post.pageAttributes.author_url,
twitter: post.pageAttributes.author_twitter,
name: article.author.fullName,
url: article.pageAttributes.author_url,
twitter: article.pageAttributes.author_twitter,
}}
/>
</p>

{post.pageAttributes.tags &&
<TagList tags={post.pageAttributes.tags}
{article.pageAttributes.tags &&
<TagList tags={article.pageAttributes.tags}
baseUrl={`${languageContexts.homeLink}tags`} />}
<TranslationsLink
translationsLink={translationsLink}
Expand All @@ -50,7 +50,7 @@ const Header = ({post, slug, translationsLink, languageContexts}) => {
}

Header.propTypes = {
post: PropTypes.object.isRequired,
article: PropTypes.object.isRequired,
slug: PropTypes.string.isRequired,
translationsLink: PropTypes.array.isRequired,
languageContexts: PropTypes.object.isRequired,
Expand Down
16 changes: 8 additions & 8 deletions src/components/Article/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import Header from './Header'
import LightWeightMarkup from './LightweightMarkup'
import Footer from './Footer'

const Article = ({post, slug, translationsLink, languageContexts}) => {
const Article = ({article, slug, translationsLink, languageContexts}) => {
return (
<article>
<Header
post={post}
slug={slug}
translationsLink={translationsLink}
languageContexts={languageContexts}
article={article}
slug={slug}
translationsLink={translationsLink}
languageContexts={languageContexts}
/>
<LightWeightMarkup html={post.html}/>
<Footer post={post}/>
<LightWeightMarkup html={article.html}/>
<Footer article={article}/>
</article>
);
}

Article.propTypes = {
post: PropTypes.object.isRequired,
article: PropTypes.object.isRequired,
slug: PropTypes.string.isRequired,
translationsLink: PropTypes.array.isRequired,
languageContexts: PropTypes.object.isRequired,
Expand Down
8 changes: 4 additions & 4 deletions src/templates/blog-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function BlogPostTemplate({ data, pageContext, location }) {
}}
/>
<Article
post={post}
slug={pageContext.slug}
translationsLink={translationsLink}
languageContexts={languageContexts}
article={post}
slug={pageContext.slug}
translationsLink={translationsLink}
languageContexts={languageContexts}
/>

<RelativePosts
Expand Down

0 comments on commit 0bdb846

Please sign in to comment.