|
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">
|
@@ -142,6 +147,7 @@ A watcher has been added to the component to render the details dynamically when
|
142 | 147 | contributors: [],
|
143 | 148 | license: '',
|
144 | 149 | author: '',
|
| 150 | + readme: '', |
145 | 151 | githubURL: 'https://www.github.com/',
|
146 | 152 | sniper_data: {},
|
147 | 153 | js_dependencies: [],
|
@@ -205,6 +211,7 @@ A watcher has been added to the component to render the details dynamically when
|
205 | 211 | value: details.forks
|
206 | 212 | }
|
207 | 213 | ];
|
| 214 | + console.log(this.githubURL.slice(0, 8) + 'api.' + this.githubURL.slice(8, 18) + '/repos' + this.githubURL.slice(18) + '/contents/README.md'); |
208 | 215 | const splitTime = time =>
|
209 | 216 | time && typeof time === 'string' ? time.split('T')[0] : undefined;
|
210 | 217 | this.stats = [
|
@@ -246,10 +253,37 @@ A watcher has been added to the component to render the details dynamically when
|
246 | 253 | this.sniper_data = result.data.sniper_data;
|
247 | 254 | this.js_dependencies = result.data.js_dependencies;
|
248 | 255 | this.css_dependencies = result.data.css_dependencies;
|
249 |
| - this.isLoading = false; |
250 | 256 | const url = `${API_URL}details/${this.name}`;
|
251 | 257 | console.log(this.sniper_data);
|
252 |
| -
|
| 258 | + axios({ |
| 259 | + method: 'GET', |
| 260 | + url: this.githubURL.slice(0, 8) + 'api.' + this.githubURL.slice(8, 18) + '/repos' + this.githubURL.slice(18) + '/contents/README.md' |
| 261 | + }).then( |
| 262 | + result => { |
| 263 | + this.readme = result.data.content; |
| 264 | + axios({ |
| 265 | + method: 'POST', |
| 266 | + url: 'https://api.github.com/markdown/raw', |
| 267 | + headers: {'Content-Type': 'text/plain'}, |
| 268 | + data: Buffer.from(result.data.content, 'base64').toString('ascii') |
| 269 | + }).then( |
| 270 | + result => { |
| 271 | + this.readme = result.data; |
| 272 | + this.isLoading = false; |
| 273 | + }, |
| 274 | + error => { |
| 275 | + this.readme = ''; |
| 276 | + this.isLoading = false; |
| 277 | + console.log(error); |
| 278 | + } |
| 279 | + ); |
| 280 | + }, |
| 281 | + error => { |
| 282 | + this.readme = ''; |
| 283 | + this.isLoading = false; |
| 284 | + console.log(error); |
| 285 | + } |
| 286 | + ); |
253 | 287 | axios({ method: 'GET', url }).then(
|
254 | 288 | result => {
|
255 | 289 | if (result.data.error) {
|
@@ -280,6 +314,13 @@ A watcher has been added to the component to render the details dynamically when
|
280 | 314 | return 'none';
|
281 | 315 | }
|
282 | 316 | },
|
| 317 | + computeReadme () { |
| 318 | + if (this.readme === '') { |
| 319 | + return 'Not available'; |
| 320 | + } else { |
| 321 | + return this.readme; |
| 322 | + } |
| 323 | + }, |
283 | 324 | computeLicense () {
|
284 | 325 | if (this.license === '') {
|
285 | 326 | return 'Not available';
|
|
0 commit comments