Skip to content
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

Conversation

nickytonline
Copy link
Contributor

@nickytonline nickytonline commented Aug 17, 2020

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.

Man sliding across the screen saying "Aww yeah!"

@netlify
Copy link

netlify bot commented Aug 17, 2020

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",
Copy link
Contributor Author

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",
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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'
Copy link
Contributor Author

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!.

@nickytonline nickytonline marked this pull request as ready for review August 17, 2020 20:36
@drewclem
Copy link
Collaborator

This is fantastic, @nickytonline!

@drewclem drewclem merged commit f41d3ba into ProjectProtege:develop Aug 18, 2020
@pickleat
Copy link
Collaborator

Hell yeah @nickytonline! I was wondering how you'd implement this to create static content. Very cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants