mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-12 00:54:45 +02:00
feat: Cache github response
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.cache
|
||||
.netlify
|
||||
_site
|
||||
node_modules
|
||||
|
@@ -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
|
||||
'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'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@@ -30,18 +30,18 @@
|
||||
<li class="footer__item"><a class="footer__link" href="https://blur.page" target="_blank">BlurPage</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://formvalidation.io" target="_blank">Form Validation</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://intersectionobserver.io" target="_blank">IntersectionObserver Examples</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://react-pdf-viewer.dev" target="_blank">React PDF Viewer</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://react-pdf-viewer.dev" target="_blank">React PDF Viewer ● {{ github.reactpdfviewer.stargazers }}★</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer__col">
|
||||
<div class="footer__heading">Learning resources</div>
|
||||
<ul class="footer__list">
|
||||
<li class="footer__item"><a class="footer__link" href="https://1loc.dev" target="_blank">1 LOC</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://crossbrowser.dev" target="_blank">Cross Browser</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://csslayout.io" target="_blank">CSS Layout</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://getfrontend.tips" target="_blank">Front-end Tips</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://htmldom.dev" target="_blank">HTML DOM</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://thisthat.dev" target="_blank">this vs that</a></li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://1loc.dev" target="_blank">1 LOC</a> ● {{ github.oneloc.stargazers }}★</li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://crossbrowser.dev" target="_blank">Cross Browser</a> ● {{ github.crossbrowser.stargazers }}★</li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://csslayout.io" target="_blank">CSS Layout</a> ● {{ github.csslayout.stargazers }}★</li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://getfrontend.tips" target="_blank">Front-end Tips</a> ● {{ github.frontendtips.stargazers }}★</li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://htmldom.dev" target="_blank">HTML DOM</a> ● {{ github.htmldom.stargazers }}★</li>
|
||||
<li class="footer__item"><a class="footer__link" href="https://thisthat.dev" target="_blank">this vs that</a> ● {{ github.thisvsthat.stargazers }}★</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer__col">
|
||||
|
@@ -9,7 +9,7 @@ layout: layouts/base.njk
|
||||
<div class="header__breadcrumb">
|
||||
<a class="header__link" href="/">/css-layout</a>
|
||||
</div>
|
||||
<a class="header__link header__link--primary" href="https://github.com/phuocng/csslayout">GitHub {{ github.stargazers }}★</a>
|
||||
<a class="header__link header__link--primary" href="https://github.com/phuocng/csslayout">GitHub {{ github.csslayout.stargazers }}★</a>
|
||||
</div>
|
||||
|
||||
{% include "css-scan.njk" %}
|
||||
|
@@ -7,7 +7,7 @@ eleventyExcludeFromCollections: true
|
||||
<div class="container">
|
||||
<div class="hero">
|
||||
<h1 class="hero__heading">A collection of popular layouts and patterns made with CSS</h1>
|
||||
<a class="hero__button" href="https://github.com/phuocng/csslayout">Star me on GitHub · {{ github.stargazers }}★</a>
|
||||
<a class="hero__button" href="https://github.com/phuocng/csslayout">Star me on GitHub ● {{ github.csslayout.stargazers }}★</a>
|
||||
</div>
|
||||
|
||||
{% include "css-scan.njk" %}
|
||||
|
@@ -32,9 +32,9 @@
|
||||
"watch:sass": "sass styles/index.scss _site/styles/index.min.css --no-source-map --style compressed --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy-fetch": "^3.0.0",
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^4.1.0",
|
||||
"html-minifier": "^4.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"prettier": "^2.7.1",
|
||||
"sass": "^1.54.8"
|
||||
},
|
||||
|
@@ -23,7 +23,7 @@
|
||||
justify-content: center;
|
||||
|
||||
/* Add a dark background */
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
background-color: #4b5563;
|
||||
}
|
||||
|
||||
.overlay-play-button__play {
|
||||
|
Reference in New Issue
Block a user