diff --git a/package.json b/package.json index 65727d0..5743c49 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "express": "^4.13.4", "front-matter": "^2.2.0", "jsonfile": "^4.0.0", - "markdown-it": "^8.4.0", + "markdown-it": "^8.4.2", "moment": "^2.19.1", "node-sass": "^4.9.0", "prop-types": "^15.7.2", diff --git a/src/components/About.js b/src/components/About.js index 3f8960a..bcd3f4d 100644 --- a/src/components/About.js +++ b/src/components/About.js @@ -3,14 +3,18 @@ import React, { Component } from 'react' import { Spinner, Header } from '.' import '../static/stylesheets/globals.scss' import contentStyle from '../static/stylesheets/content.scss' +import MarkdownIt from 'markdown-it' export default class About extends Component { static propTypes = { isLoading: PropTypes.bool.isRequired, - about: PropTypes.object.isRequired + about: PropTypes.string.isRequired } render () { + const md = MarkdownIt() + const result = md.render(this.props.about) + if (this.props.isLoading) { return (
@@ -22,7 +26,7 @@ export default class About extends Component { return (
-
+
) diff --git a/src/components/Post.js b/src/components/Post.js index f3f925c..fd146bc 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -4,6 +4,7 @@ import { Spinner, Header, Navbar } from '.' import '../static/stylesheets/globals.scss' import contentStyle from '../static/stylesheets/content.scss' import styles from './Post.scss' +import MarkdownIt from 'markdown-it' export default class Post extends Component { static propTypes = { @@ -12,6 +13,9 @@ export default class Post extends Component { } render () { + const md = MarkdownIt() + const result = md.render(this.props.post) + if (this.props.isLoading) { return (
@@ -29,7 +33,7 @@ export default class Post extends Component {

{this.props.post.published}

-
+
diff --git a/src/containers/MainContainer.js b/src/containers/MainContainer.js index 0a334e1..0945471 100644 --- a/src/containers/MainContainer.js +++ b/src/containers/MainContainer.js @@ -19,17 +19,16 @@ export default class MainContainer extends Component { data = props.staticContext.data } - console.log(data) - this.state = { isLoadingBlog: !data.posts, - isLoadingAbout: !data.about, - about: data.about, + isLoadingAbout: !data.other.about, + about: data.other.about, posts: data.posts } } render () { + console.log(this.state) return (
diff --git a/src/containers/PostContainer.js b/src/containers/PostContainer.js index 7dcc772..8072ef3 100644 --- a/src/containers/PostContainer.js +++ b/src/containers/PostContainer.js @@ -19,6 +19,8 @@ export default class PostContainer extends Component { post = props.staticContext.data } + console.log(post) + this.state = { isLoading: !post, error: false, diff --git a/src/utils/api.js b/src/utils/api.js index 65aeedb..60ce33c 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -7,7 +7,7 @@ export function getData (reqPath = '') { if (reqPath === '') { return readData(config.dataPath) } else { - const fileName = path.join(process.cwd(), 'renders/', reqPath + '.html') + const fileName = path.join(process.cwd(), config.contentPath, reqPath + '.md') return readFile(fileName, 'utf8') } }; diff --git a/src/utils/scanner.js b/src/utils/scanner.js index 0719dd8..5bc45d1 100644 --- a/src/utils/scanner.js +++ b/src/utils/scanner.js @@ -62,9 +62,7 @@ export class Scanner { this.data.posts.push(post) } else { - this.data.other.push({ - [metadata.filename]: data - }) + this.data.other[metadata.filename] = data } } diff --git a/webpack.config.js b/webpack.config.js index 8696b4e..48b9b72 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -131,7 +131,7 @@ const serverConfig = { fileName: 'data.json', content: JSON.stringify({ 'posts': [], - 'other': [] + 'other': {} }) }) ] diff --git a/yarn.lock b/yarn.lock index 8455d39..32543ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5008,9 +5008,10 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -markdown-it@^8.4.0: - version "8.4.1" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.1.tgz#206fe59b0e4e1b78a7c73250af9b34a4ad0aaf44" +markdown-it@^8.4.2: + version "8.4.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54" + integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ== dependencies: argparse "^1.0.7" entities "~1.1.1"