turn code examples into javascript and update readme

This commit is contained in:
Riku Rouvila
2015-05-21 00:32:25 +03:00
parent f716e5fe73
commit 7ff4d2a887
6 changed files with 70 additions and 32 deletions

View File

@@ -1 +0,0 @@
console.log 'foobar'

33
src/js/main.js Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
import {partialRight, invoke} from 'lodash';
Promise.all([
fetch('https://api.github.com/repos/leonidas/gulp-project-template'),
fetch('https://api.github.com/repos/leonidas/gulp-project-template/commits')
])
.then(partialRight(invoke, 'json'))
.then(Promise.all.bind(Promise))
.then(data => {
const [repository, commits] = data;
const {html_url, description, full_name} = repository;
const commitItems = commits.map(item => {
const {commit} = item;
return `
<li>
<span>${commit.message.replace(/\n/g, '<br />')}<span>
<br /><br />
<small>${commit.committer.name}</small>
</li>`;
});
document.body.innerHTML = `
<h1>${description}</h1>
<h2><a href="${html_url}">${full_name}</a></h2>
<ul>${commitItems.join('')}</ul>
`;
});

View File

@@ -1,2 +1,23 @@
body, html
margin 0
padding 1em
font 14px/1.4 'Helvetica Neue', Helvetica, Arial
color #333
li
margin 1em 0
padding 1em 0
border-bottom 1px solid #eee
h1
margin-bottom 0
h2
margin-top 0
ul
margin-top 2em
li
small
color #777