forked from 10secondsofcode/10secondsofcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
executable file
·128 lines (118 loc) · 3.57 KB
/
App.js
File metadata and controls
executable file
·128 lines (118 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React, { Fragment, Component } from "react";
import { Button } from 'reactstrap';
import { BrowserRouter, Route } from 'react-router-dom';
import Navigation from './Components/Navigation';
import Main from './Components/Main';
import Login from './Components/login';
import Herocontent from './Components/Herocontent';
import ReactMarkdown from 'react-markdown';
import AppMarkdown from '../README.md';
const markdownContext = require.context('../docs', false, /\.md$/);
const markdownFiles = markdownContext
.keys()
//.map((filename) => markdownContext(filename))
//console.log("hey"+markdownFiles);
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 5,
posts1: []
}
}
componentDidMount() {
var newPosts = [];
const posts = markdownFiles.forEach(
(file, key) => {
newPosts.push({
id: key,
data: "." + file
});
}
);
newPosts.map(
(post) => {
let a = 10;
console.log("new values===>" + post.data);
let av = this.apiGetAll(post.data);
console.log("json--->" + JSON.stringify(av));
}
);
//this.apiGetAll(newPosts["data"]);
return false;
}
async apiGetAll(newPosts) {
let cc = [];
try {
const resp = await fetch(newPosts).then(res => res.text());
console.log("fetch---" + resp);
cc.push({
data: resp
});
console.log("json--->" + JSON.stringify(cc));
/* const newResp = await Promise.all((resp)).then(result => {
console.log("hey--->"+result);
this.setState({posts1: result});
});*/
// this.setState({posts1: resp});
// console.log("dsffdsf===="+this.state.posts1);
return resp;
} catch (err) {
console.log(err);
}
}
/*getFileResults(newPosts) {
let data = [];
Promise.all(
newPosts.forEach(
(file) => {
fetch(file.data)
.then( res => res.text() )
.then(
text =>
{
console.log("text===>"+text);
data.push(text);
return data;
//this.setState((state) => ({ ...state, posts1 }));
}
)
}
)
).then(result => {
const [ data ] = result;
console.log("hey--->"+result);
});
}*/
render() {
return (
<div>
<BrowserRouter>
<Navigation />
<Route exact path="/" component={Herocontent} />
<Route path="/login" component={Login} />
<Fragment>
<section className="section">
<div className="container">
<div className="card">
<div className="card-content">
<div className="content">
{
//newPosts.map((post, idx) => (
// this.state.posts1
// ))
}
<ReactMarkdown source={this.state.posts1} />
</div>
</div>
</div>
</div>
</section>
</Fragment>
</BrowserRouter>
</div>
);
}
}
export default App;
//https://medium.com/@shawnstern/importing-multiple-markdown-files-into-a-react-component-with-webpack-7548559fce6f