-
-
Notifications
You must be signed in to change notification settings - Fork 522
chore: Update contributors list for footer #742
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
chore: Update contributors list for footer #742
Conversation
|
I'm guessing this is because of paging? I wonder if there's a way to pull the full list from all repos under the preactjs org. Maybe through the GraphQL API... |
|
Edit: Didn't realize GH capped the list to 100 contributors arbitrarily. Makes sense.
Will go get the full list of people. |
|
Running this in a JS console should return a deduped list of names for all org repos, but it hits GitHub's rate limit (or at least it did for me after running it twice): https://gist.github.com/developit/d8c53ec368d56ca113b191dd5a3642b4 |
|
So there's a tad few more names now.... This PR brought the list from 32 to 565! |
|
now that I think of it, we should inject these at build time to avoid putting all the names in the client-side JS. I can try to come up with a hacky solution... |
|
That did dawn on me once I saw the number of names. Could set up some tiny API too to return a random name. The footer is a pretty safe place to have a flash of content as the name changes. |
|
@rschristian yeah either that or a JSON file that we fetch lazily seems like the way to go here. We can still either "bake in" one name randomly each time the site gets prerendered, or even just have the initial footer not include a name and it only gets injected when changing the URL. For the API thing, we currently have two Netlify functions, this could be a third? I think I'm slightly inclined to try the simple JSON-file-loaded-via-fetch approach first since it's free. Something like: footer.js: -const CONTRIBS = ' <snip> '
+let contributors;
export function useContributors(deps) {
- const [value, setValue] = useState(CONTRIBS[new Date().getMonth()]);
+ const [value, setValue] = useState(contributors ? contributors[new Date().getMonth()] : undefined);
+ useEffect(() => {
+ fetch('/assets/contributors.json').then(r => r.json()).then(data => contributors = data);
+ }, []);
useEffect(() => {
- setValue(CONTRIBS[(Math.random() * (CONTRIBS.length - 1)) | 0]);
+ if (contributors) {
+ setValue(contributors[(Math.random() * (contributors.length - 1)) | 0]);
+ }
}, deps);
return value;
}... then later on: <p style="line-height: 1">
Built by a bunch of{' '}
<a
href="https://github.com/preactjs/preact/graphs/contributors"
target="_blank"
rel="noopener noreferrer"
>
lovely people
- </a>{' '}
- like{' '}
+ </a>
+ {contrib && [
+ ' like ',
<a
href={'https://github.com/' + contrib}
target="_blank"
rel="noopener noreferrer"
>
@{contrib}
</a>
+ ]}
.
</p> |
|
Totally forgot about this thing. Will try to figure out something tomorrow. Whoops! |
|
@developit Should (hopefully) be good now. Went with the static JSON file as you suggested. Will be ~4.5kb of transferred JSON but I'm guessing that should be okay. As a side note, we're up 92 unique new contributors to PreactJS repos since Jan 14 which is pretty cool! ~15% of the total unique contributors to the org have contributed for the first time in the last 95 or so days. |
* chore: Update contributors list for footer (#742) * chore: Update contributors list for footer * refactor: All names, all repos * refactor: Updating contributor list + retrieval method * docs: Adding additional comment to contributors list update * fix: Typo in jsdoc * filter contribs to 2+ to keep size down * Update index.js Co-authored-by: Ryan Christian <[email protected]>
This list hasn't been update in about a year and a half or so, since it was first created. I think it's due for an update, as quite a few new names have helped out since then.
Edit: Though now that I look a bit more closely, there's a couple names from the old list that aren't in the new. Is there another list that should be appended in? Not sure how that should be handled.