Skip to content

Commit

Permalink
Added timeago for quickly converting a Date object into '3 days ago…
Browse files Browse the repository at this point in the history
…' or similar.
  • Loading branch information
pschfr committed Feb 14, 2019
1 parent 0dd824b commit 60d846d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const timeago = require('timeago.js');
const repos = require('github-user-repos');
const opts = {
'token': process.env.GITHUB_TOKEN,
Expand All @@ -16,9 +17,14 @@ function callback(error, results, info) {
if (error) {
throw new Error(error.message);
}
console.log(JSON.stringify(results));
// console.log(JSON.stringify(results));
// returns <repo_data>

// Converts a DateTime value to '3 days ago' or similar, adds it to data file.
results.forEach(element => {
element['updated_at_timeago'] = timeago.format(element['updated_at']);
});

fs.mkdir('public/repos', { recursive: true }, (err) => {
// if (err) throw err;
});
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
},
"keywords": [
"harp",
"harpjs"
"harpjs",
"github-user-repos",
"timeago",
"timeago.js"
],
"author": "Paul Schaefer",
"license": "MIT",
Expand All @@ -23,6 +26,7 @@
"homepage": "https://github.com/pschfr/labs#readme",
"dependencies": {
"github-user-repos": "^1.0.2",
"harp": "^0.29.0"
"harp": "^0.29.0",
"timeago.js": "^4.0.0-beta.2"
}
}
4 changes: 3 additions & 1 deletion public/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ ul
| Description: #{repo['description']}<br/>
if repo['homepage']
| URL:
a(href="#{repo['homepage']}")= repo['homepage']
a(href="#{repo['homepage']}") #{repo['homepage']} <br/>
| Last updated:
time(datetime="#{repo['updated_at']}") #{repo['updated_at_timeago']}
br

0 comments on commit 60d846d

Please sign in to comment.