diff --git a/.gitignore b/.gitignore index 8d50cfd..f459e3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.cache .netlify _site node_modules diff --git a/contents/_data/github.js b/contents/_data/github.js index d834660..c0ed939 100644 --- a/contents/_data/github.js +++ b/contents/_data/github.js @@ -1,11 +1,24 @@ -const fetch = require('node-fetch'); +const EleventyFetch = require("@11ty/eleventy-fetch") + +async function fetchGitHubStars(repos) { + let json = await EleventyFetch(`https://api.github.com/repos/${repos}`, { + duration: '1d', + type: 'json' + }); + + return { + stargazers: json.stargazers_count, + }; +} module.exports = async function() { - return fetch('https://api.github.com/repos/phuocng/csslayout') - .then(res => res.json()) - .then(json => { - return { - stargazers: json.stargazers_count - }; - }); + return { + 'oneloc': await fetchGitHubStars('phuocng/1loc'), + 'crossbrowser': await fetchGitHubStars('phuocng/cross-browser'), + 'csslayout': await fetchGitHubStars('phuocng/csslayout'), + 'frontendtips': await fetchGitHubStars('phuocng/frontend-tips'), + 'htmldom': await fetchGitHubStars('phuocng/html-dom'), + 'thisvsthat': await fetchGitHubStars('phuocng/this-vs-that'), + 'reactpdfviewer': await fetchGitHubStars('react-pdf-viewer/react-pdf-viewer'), + }; }; diff --git a/contents/_includes/layouts/base.njk b/contents/_includes/layouts/base.njk index e22f82d..dca5669 100644 --- a/contents/_includes/layouts/base.njk +++ b/contents/_includes/layouts/base.njk @@ -30,18 +30,18 @@