-
-
Notifications
You must be signed in to change notification settings - Fork 945
fix(ui): improve GitHub star badge layout and alignment #6326
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
Changes from all commits
fdd0403
a6354af
198d348
683ccda
60714f8
436d871
854c116
8ab8ac0
adec102
96d25c0
7537e94
58d2a9e
6b8d48b
53a96a3
46be415
da07b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // This file is auto-updated by xtasks/release-plz | ||
| // Current star count from GitHub API | ||
| export default { | ||
| load() { | ||
| return { | ||
| stars: "19.3k", | ||
| }; | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,37 @@ import DefaultTheme from "vitepress/theme"; | |
| import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client"; | ||
| import "virtual:group-icons.css"; | ||
| import "./custom.css"; | ||
| import { onMounted } from "vue"; | ||
| import { data as starsData } from "../stars.data"; | ||
|
|
||
| export default { | ||
| extends: DefaultTheme, | ||
| enhanceApp({ app }) { | ||
| enhanceAppWithTabs(app); | ||
| }, | ||
| setup() { | ||
| onMounted(() => { | ||
| // Add star count to GitHub social link | ||
| const addStarCount = () => { | ||
| const githubLink = document.querySelector( | ||
| '.VPSocialLinks a[href*="github.com/jdx/mise"]', | ||
| ); | ||
| if (githubLink && !githubLink.querySelector(".star-count")) { | ||
| const starBadge = document.createElement("span"); | ||
| starBadge.className = "star-count"; | ||
| starBadge.innerHTML = starsData.stars; | ||
| starBadge.title = "GitHub Stars"; | ||
| githubLink.appendChild(starBadge); | ||
| } | ||
| }; | ||
|
|
||
| // Try immediately and after a short delay to ensure DOM is ready | ||
| addStarCount(); | ||
| setTimeout(addStarCount, 100); | ||
|
|
||
| // Also watch for route changes | ||
| const observer = new MutationObserver(addStarCount); | ||
| observer.observe(document.body, { childList: true, subtree: true }); | ||
|
Comment on lines
+35
to
+36
|
||
| }); | ||
| }, | ||
| } satisfies Theme; | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,6 +79,33 @@ sed -i.bak "s/^[0-9]\+\.[0-9]\+\.[0-9]\+\(-rc\.[0-9]\+\)\? macos-arm64 (a1b2d3e | |||||||||
| sed -i.bak "s/^Version: [0-9]\+\.[0-9]\+\.[0-9]\+\(-rc\.[0-9]\+\)\?$/Version: $version/" packaging/rpm/mise.spec | ||||||||||
| sed -i.bak "s/version = \"[0-9]\+\.[0-9]\+\.[0-9]\+\(-rc\.[0-9]\+\)\?\";$/version = \"$version\";/" default.nix | ||||||||||
|
|
||||||||||
| # Update GitHub star count using gh CLI | ||||||||||
| stars_raw="$(gh api repos/jdx/mise --jq '.stargazers_count')" | ||||||||||
| if [[ -n $stars_raw ]]; then | ||||||||||
| if [[ $stars_raw -ge 1000 ]]; then | ||||||||||
| # Format as k notation (e.g., 19346 -> 19.3k) | ||||||||||
| stars_formatted="$(echo "scale=1; $stars_raw / 1000" | bc)k" | ||||||||||
|
||||||||||
| stars_formatted="$(echo "scale=1; $stars_raw / 1000" | bc)k" | |
| int_part=$((stars_raw / 1000)) | |
| frac_part=$(( (stars_raw % 1000) / 100 )) | |
| stars_formatted="${int_part}.${frac_part}k" |
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.
Bug: GitHub API Response Validation Error
The release-plz script fetches GitHub stars but doesn't validate the API response. If stars_raw is non-numeric (e.g., API error message, jq returning "null"), numeric operations fail, either crashing the script or writing "null" to the stars data file, which then displays incorrectly on the website.
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.
Using negative margins with
!importantdeclarations can make the layout fragile and hard to maintain. Consider using a more stable positioning approach or specific flex layout properties to achieve the desired spacing.