From 5e7fbcd3a4410fc0dc3eab1ecb362b8295fea2d5 Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Sat, 7 Oct 2017 15:11:21 -0700 Subject: [PATCH] Fix Article/Post naming Post/Posts is better than FullArticle/Articles since that's really what they are. Paves the way for a Page to render an Article. --- src/App.js | 10 +++++----- src/Article.js | 42 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/App.js b/src/App.js index a49fb4f..380a57f 100644 --- a/src/App.js +++ b/src/App.js @@ -10,7 +10,7 @@ import 'highlight.js/styles/github-gist.css'; import { Container, Row, Column } from './skeleton'; -import { Articles, FullArticle } from './Article'; +import { Post, Posts } from './Article'; import { Footer } from './Footer'; import { Header } from './Header'; import { NavList, TagNav, HistoryNav } from './Nav'; @@ -37,13 +37,13 @@ class App extends Component { - + { /* Page routes */ } - { /* Article routes */ } - - + { /* Post routes */ } + + { /* 404 fallback */ } diff --git a/src/Article.js b/src/Article.js index 332fea4..cfd0324 100644 --- a/src/Article.js +++ b/src/Article.js @@ -83,18 +83,18 @@ class Article extends Component { } -class FullArticle extends Component { +class Post extends Component { constructor(props) { super(props); this.props = props; this.params = props.match.params; this.state = { - article: null + post: null } } - fetchArticle() { + fetchPost() { fetch('/site.json') .then((resp) => resp.json()) .then((blob) => { @@ -106,33 +106,33 @@ class FullArticle extends Component { } if (slug === this.params.slug) { - this.setState({article: post}) + this.setState({post: post}) found = true; break } } if (!found) { - console.log('article not found'); + console.log('post not found'); /* TODO: return 404 */ } }); } componentDidMount() { - this.fetchArticle(); + this.fetchPost(); } componentWillReceiveProps(props) { this.params = props.match.params; - this.fetchArticle(); + this.fetchPost(); } render() { - if (this.state.article) { + if (this.state.post) { return (
) } else { @@ -143,7 +143,7 @@ class FullArticle extends Component { } } -class Articles extends Component { +class Posts extends Component { constructor(props) { super(props); @@ -153,12 +153,12 @@ class Articles extends Component { this.params = props.match.params; this.state = { - articles: null, + posts: null, } } - fetchArticles() { - // Fetch articles from JSON blob + fetchPosts() { + // Fetch posts from JSON blob fetch('/site.json') .then((resp) => resp.json()) .then((blob) => { @@ -168,25 +168,25 @@ class Articles extends Component { } let posts = blob.posts.slice(offset, offset + this.per_page); - this.setState({articles: posts}); + this.setState({posts: posts}); }); } componentDidMount() { - this.fetchArticles(); + this.fetchPosts(); } componentWillReceiveProps(props) { this.params = props.match.params; - this.fetchArticles(); + this.fetchPosts(); } render() { - if (this.state.articles != null) { - let articles = this.state.articles.map(article => + if (this.state.posts != null) { + let articles = this.state.posts.map(post =>
); @@ -205,4 +205,4 @@ class Articles extends Component { } } -export { Article, FullArticle, Articles }; +export { Article, Post, Posts };