New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/generate contributors json #115
Feature/generate contributors json #115
Conversation
Deploy request for affectionate-goldberg-7cf473 rejected. Rejected with commit 9006f41 https://docs.netlify.com/configure-builds/environment-variables/#sensitive-variable-policy |
@@ -59,6 +62,7 @@ | |||
"eslint-plugin-prettier": "^3.1.3", | |||
"eslint-plugin-react": "^7.19.0", | |||
"eslint-plugin-react-hooks": "^2.5.0", | |||
"node-fetch": "^2.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets us use fetch
in Node so we can call the GitHub API in our script that generates the contributors.json file.
@@ -24,7 +24,10 @@ | |||
"yup": "^0.28.3" | |||
}, | |||
"scripts": { | |||
"get-contributors": "bin/generate-contributors-json.js", | |||
"prestart": "npm run get-contributors", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre
scripts are present so that the contributors.json file will be created when npm run start
or npm run build
is executed.
import Layout from '../layouts/Layout' | ||
import { motion } from 'framer-motion' | ||
import contributors from '../data/contributors.json' | ||
|
||
function blogLinkFormatter(url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this out of the component as it requires no component state.
className='rounded-full h-24 w-24 mx-auto' | ||
src={avatar_url} | ||
alt={`${name} avatar`} | ||
loading='lazy' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the loading="lazy"
attribute to improve page load. See Native image lazy-loading for the web!.
This is fantastic, @nickytonline! |
Hell yeah @nickytonline! I was wondering how you'd implement this to create static content. Very cool. |
Description
Implements #116.
With this PR, a contributors.json file is created at build time now (includes the OG contributors just like before).
When the Contributors page is accessed, instead of hitting the GitHub API to retrieve the contributors list, it will now be passed in as a prop to the
ContributorsList
component, i.e.<ContribtorsList contributors={contributors} />
.The result is a faster page load for the contributors page with no additional network requests.