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

show GitHub stars in header #1125

Merged
merged 2 commits into from Mar 22, 2024
Merged

show GitHub stars in header #1125

merged 2 commits into from Mar 22, 2024

Conversation

mbostock
Copy link
Member

Screenshot 2024-03-21 at 8 13 30 PM

@mbostock mbostock requested a review from Fil March 22, 2024 03:14
@mbostock mbostock enabled auto-merge (squash) March 22, 2024 03:14
@@ -1,3 +1,7 @@
import {formatPrefix} from "d3-format";

const {stargazers_count} = await github("/repos/observablehq/framework").catch(() => ({stargazers_count: 4242}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd default to null or undefined if the github API call fails. This might require an additional test below to avoid showing 0.0k/NaNk stars (although it could be ok too to show NaN if we can't get the information).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only thinking of local development. In CI I’d want the deploy to fail if we’re not able to talk to GitHub, so that we always show the correct star count. I’ve changed the code to rethrow in CI.

@mbostock mbostock requested a review from Fil March 22, 2024 15:16
@mbostock mbostock merged commit 2dd3082 into main Mar 22, 2024
4 checks passed
@mbostock mbostock deleted the mbostock/github-stars branch March 22, 2024 15:18
@mbostock
Copy link
Member Author

We may want some caching if we load the config lazily on each request… #695

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

2 participants