Skip to content

Commit 1ff2acf

Browse files
committed
feat(docs): add Github stars component
1 parent f9d153f commit 1ff2acf

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

.vscode/settings.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"gpt-context-generator.detectedFileExtensions": [
3-
"js",
4-
"jsx",
5-
"ts",
6-
"tsx",
7-
"mdx",
83
"json",
94
"swift",
105
"plist",
116
"pbxproj",
127
"entitlements",
138
"md",
149
"yml",
15-
"html"
10+
"html",
11+
"astro",
12+
"ts",
13+
"mjs",
14+
"scss",
15+
"CNAME",
16+
"Dockerfile"
1617
],
1718
"markdownlint.config": {
1819
"default": true,

docs/src/components/GithubStars.astro

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
// docs/src/components/GithubStars.astro
3+
const REPO = "codybrom/blankie";
4+
5+
async function getStarCount() {
6+
try {
7+
const response = await fetch(`https://api.github.com/repos/${REPO}`);
8+
const data = await response.json();
9+
return data.stargazers_count;
10+
} catch (error) {
11+
console.error("Error fetching GitHub stars:", error);
12+
return null;
13+
}
14+
}
15+
16+
const stars = await getStarCount();
17+
---
18+
19+
<a
20+
href={`https://github.com/${REPO}`}
21+
target="_blank"
22+
rel="noopener noreferrer"
23+
class="inline-flex items-center text-sm group"
24+
title="Star us on GitHub"
25+
>
26+
<span
27+
class="inline-flex items-center gap-1.5 px-3 py-1 font-medium bg-[#f6f8fa] border border-[#1b1f2426] rounded-l-md hover:bg-[#f3f4f6] text-[#24292f] dark:bg-[#21262d] dark:border-[#f0f6fc1a] dark:text-[#c9d1d9] dark:hover:bg-[#30363d] transition-colors duration-200"
28+
>
29+
<svg
30+
viewBox="0 0 16 16"
31+
width="16"
32+
height="16"
33+
class="inline-block fill-current"
34+
aria-hidden="true"
35+
>
36+
<path
37+
d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"
38+
></path>
39+
</svg>
40+
<span>Github Stars</span>
41+
</span>
42+
{
43+
stars !== null && (
44+
<span class="inline-flex items-center px-3 py-1 font-medium bg-[#f6f8fa] border border-l-0 border-[#1b1f2426] rounded-r-md hover:bg-[#f3f4f6] text-[#24292f] dark:bg-[#21262d] dark:border-[#f0f6fc1a] dark:text-[#c9d1d9] dark:hover:bg-[#30363d] transition-colors duration-200">
45+
{new Intl.NumberFormat("en-US").format(stars)}
46+
</span>
47+
)
48+
}
49+
</a>

docs/src/components/Nav.astro

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import { Image } from "astro:assets";
33
import icon from "../assets/icon.png";
4+
import GithubStars from "./GithubStars.astro";
45
const currentPath = Astro.url.pathname;
56
---
67

@@ -82,6 +83,7 @@ const currentPath = Astro.url.pathname;
8283
>
8384
Credits
8485
</a>
86+
<GithubStars />
8587
<a
8688
href="/?section=download"
8789
class="bg-primary-blue text-white py-2 px-6 rounded-full text-sm font-normal transition-all duration-300 hover:bg-deep-blue no-underline"
@@ -121,6 +123,7 @@ const currentPath = Astro.url.pathname;
121123
>
122124
Credits
123125
</a>
126+
<GithubStars />
124127
<a
125128
href="/?section=download"
126129
class="bg-primary-blue text-white py-2 px-6 rounded-full text-sm font-normal transition-all duration-300 hover:bg-deep-blue no-underline inline-block text-center"

docs/src/layouts/Layout.astro

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const description = "Ambient sound mixer for macOS.";
2727

2828
<meta
2929
http-equiv="Content-Security-Policy"
30-
content="default-src 'self'; img-src 'self' data: https:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';"
30+
content="default-src 'self'; img-src 'self' data: https:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src 'self' api.github.com;"
3131
/>
3232

3333
<link rel="icon" type="image/x-icon" href={favicon} />

0 commit comments

Comments
 (0)