Getting posts and about rendered
This commit is contained in:
parent
2eb8acf315
commit
e6d2c55c1f
|
@ -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",
|
||||
|
|
|
@ -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 (
|
||||
<div className={contentStyle.contentWrapper} id="about">
|
||||
|
@ -22,7 +26,7 @@ export default class About extends Component {
|
|||
return (
|
||||
<div className={contentStyle.contentWrapper} id="about">
|
||||
<Header header={'About Me'} />
|
||||
<div className={contentStyle.content} dangerouslySetInnerHTML={{ __html: this.props.about.body }}>
|
||||
<div className={contentStyle.content} dangerouslySetInnerHTML={{ __html: result }}>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -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 (
|
||||
<div className={contentStyle.contentWrapper}>
|
||||
|
@ -29,7 +33,7 @@ export default class Post extends Component {
|
|||
<div className={styles.postDate}>
|
||||
<h3>{this.props.post.published}</h3>
|
||||
</div>
|
||||
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: this.props.post.body }}>
|
||||
<div className={styles.postContent} dangerouslySetInnerHTML={{ __html: result }}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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 (
|
||||
<div>
|
||||
<Home/>
|
||||
|
|
|
@ -19,6 +19,8 @@ export default class PostContainer extends Component {
|
|||
post = props.staticContext.data
|
||||
}
|
||||
|
||||
console.log(post)
|
||||
|
||||
this.state = {
|
||||
isLoading: !post,
|
||||
error: false,
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ const serverConfig = {
|
|||
fileName: 'data.json',
|
||||
content: JSON.stringify({
|
||||
'posts': [],
|
||||
'other': []
|
||||
'other': {}
|
||||
})
|
||||
})
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue