|
85 | 85 | <contributor v-for="contributor in contributors" :key="contributor.id" :imageURL="contributor.avatar_url" :name="contributor.username" />
|
86 | 86 | </div>
|
87 | 87 | </div>
|
| 88 | + <div id="readme" class="section"> |
| 89 | + <div class="title">README</div> |
| 90 | + <div class="content" v-html="computeReadme ()"> |
| 91 | + </div> |
| 92 | + </div> |
88 | 93 | <div id="legal" class="section">
|
89 | 94 | <div class="title">Legal</div>
|
90 | 95 | <div class="content">
|
@@ -144,6 +149,7 @@ A watcher has been added to the component to render the details dynamically when
|
144 | 149 | contributors: [],
|
145 | 150 | license: '',
|
146 | 151 | author: '',
|
| 152 | + readme: '', |
147 | 153 | githubURL: 'https://www.github.com/',
|
148 | 154 | sniper_data: {},
|
149 | 155 | js_dependencies: [],
|
@@ -250,10 +256,38 @@ A watcher has been added to the component to render the details dynamically when
|
250 | 256 | this.sniper_data = result.data.sniper_data;
|
251 | 257 | this.js_dependencies = result.data.js_dependencies;
|
252 | 258 | this.css_dependencies = result.data.css_dependencies;
|
253 |
| - this.isLoading = false; |
254 | 259 | const url = `${API_URL}details/${this.name}`;
|
255 | 260 | console.log(this.sniper_data);
|
256 | 261 |
|
| 262 | + axios({ |
| 263 | + method: 'GET', |
| 264 | + url: `https://api.github.com/repos/${this.githubURL.slice(19)}/contents/README.md` |
| 265 | + }).then( |
| 266 | + result => { |
| 267 | + this.readme = result.data.content; |
| 268 | + axios({ |
| 269 | + method: 'POST', |
| 270 | + url: 'https://api.github.com/markdown/raw', |
| 271 | + headers: {'Content-Type': 'text/plain'}, |
| 272 | + data: Buffer.from(result.data.content, 'base64').toString('ascii') |
| 273 | + }).then( |
| 274 | + result => { |
| 275 | + this.readme = result.data; |
| 276 | + this.isLoading = false; |
| 277 | + }, |
| 278 | + error => { |
| 279 | + this.readme = ''; |
| 280 | + this.isLoading = false; |
| 281 | + console.log(error); |
| 282 | + } |
| 283 | + ); |
| 284 | + }, |
| 285 | + error => { |
| 286 | + this.readme = ''; |
| 287 | + this.isLoading = false; |
| 288 | + console.log(error); |
| 289 | + } |
| 290 | + ); |
257 | 291 | axios({ method: 'GET', url }).then(
|
258 | 292 | result => {
|
259 | 293 | if (result.data.error) {
|
@@ -284,6 +318,13 @@ A watcher has been added to the component to render the details dynamically when
|
284 | 318 | return 'none';
|
285 | 319 | }
|
286 | 320 | },
|
| 321 | + computeReadme () { |
| 322 | + if (this.readme === '') { |
| 323 | + return 'Not available'; |
| 324 | + } else { |
| 325 | + return this.readme; |
| 326 | + } |
| 327 | + }, |
287 | 328 | computeLicense () {
|
288 | 329 | if (this.license === '') {
|
289 | 330 | return 'Not available';
|
@@ -406,6 +447,11 @@ A watcher has been added to the component to render the details dynamically when
|
406 | 447 | // margin-top: -20px;
|
407 | 448 | color: rgba(0, 0, 0, 0.7);
|
408 | 449 | }
|
| 450 | +#readme { |
| 451 | + * { |
| 452 | + overflow-x: auto; |
| 453 | + } |
| 454 | +} |
409 | 455 | #biojsio {
|
410 | 456 | width: 80%;
|
411 | 457 | border-radius: 3px;
|
|
0 commit comments