mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-24 11:16:27 +02:00
feat: Cache github response
This commit is contained in:
@@ -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'),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user