Skip to content

Commit 7df2ba0

Browse files
committed
added
1 parent 93c4808 commit 7df2ba0

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

.babelrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"presets": [
33
"@babel/preset-env",
44
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"@babel/transform-runtime"
58
]
6-
}
7-
8-
9+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"homepage": "http://10secondsofcode.github.io/10secondsofcode",
3232
"devDependencies": {
3333
"@babel/core": "^7.0.0",
34+
"@babel/plugin-transform-runtime": "^7.2.0",
3435
"@babel/preset-env": "^7.0.0",
3536
"@babel/preset-react": "^7.0.0",
3637
"babel-eslint": "^10.0.1",
@@ -54,6 +55,8 @@
5455
"webpack-dev-server": "^3.1.8"
5556
},
5657
"dependencies": {
58+
"@babel/polyfill": "^7.2.5",
59+
"@babel/runtime": "^7.3.1",
5760
"bootstrap": "^4.1.3",
5861
"front-matter-loader": "^0.2.0",
5962
"jquery": "^3.3.1",

src/App.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,47 @@ import Herocontent from './Components/Herocontent';
77
import ReactMarkdown from 'react-markdown';
88
import AppMarkdown from '../README.md';
99

10-
const importAll = (r) => r.keys().map(r);
11-
const markdownFiles = importAll(require.context('../docs', false, /\.md$/))
12-
.sort()
13-
.reverse();
10+
// const importAll = (r) => r.keys().map(r);
11+
// const markdownFiles = importAll(require.context('../docs', false, /\.md$/))
12+
// .sort()
13+
// .reverse();
1414

1515
//console.log("markdownFiles====>"+markdownFiles);
1616

17+
// const markdownContext = require.context('../docs', false, /\.md$/);
18+
// console.log(markdownContext.keys());
19+
20+
// function importAll (r) {
21+
// r.keys().forEach(r);
22+
// }
23+
24+
/* importAll(require.context('../docs/', true, /\.js$/));
25+
26+
const markdownContext = require.context('../docs', false, /\.md$/);
27+
const markdownFiles = markdownContext
28+
.keys()
29+
.map((filename) => markdownContext(filename))
30+
console.log(markdownFiles); */
31+
32+
const importAll = (r) => r.keys().map(r);
33+
const markdownFiles = importAll(require.context('../docs/', false, /\.md$/));
34+
1735
class App extends React.Component {
1836
constructor(props){
1937
super(props);
2038
this.state = {
2139
count : 5,
22-
markdown: ''
40+
posts: ''
2341
}
2442
this.increment = this.increment.bind(this);
2543
this.decrement = this.decrement.bind(this);
2644
}
2745

28-
componentDidMount() {
46+
async componentDidMount() {
2947
console.log(markdownFiles);
30-
const markdown = Promise.all(markdownFiles.map(
31-
(file) => fetch(file).then((res) => res.text())
32-
)).catch((err) => console.error(err));
48+
const posts = markdownFiles
3349

34-
this.setState((state) => ({ ...state, markdown }));
50+
this.setState((state) => ({ ...state, posts }));
3551
}
3652

3753
increment() {
@@ -47,7 +63,8 @@ class App extends React.Component {
4763
}
4864

4965
render() {
50-
const { markdown } = this.state;
66+
const { posts } = this.state;
67+
//console.log("post===>"+posts);
5168
return (
5269
<div>
5370
<Navigation />
@@ -59,7 +76,11 @@ class App extends React.Component {
5976
<div className="card">
6077
<div className="card-content">
6178
<div className="content">
62-
<ReactMarkdown source={markdown} />
79+
{
80+
//posts.map((post, idx) => (
81+
<ReactMarkdown source={posts} />
82+
//))
83+
}
6384
</div>
6485
</div>
6586
</div>

0 commit comments

Comments
 (0)