Skip to content

Commit 06289c9

Browse files
committed
Add GitHub star count to navbar and update documentation
1 parent d3f49f3 commit 06289c9

5 files changed

Lines changed: 81 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ npm run serve # serve the production build locally
1717

1818
- Pages are Markdown/MDX files under `docs/`; the sidebar is defined in `sidebars.js`.
1919
- Math is supported with KaTeX: inline `$T$` and block `$$ ... $$`.
20-
- `docs/` always holds the **unreleased** docs ("Next" in the version dropdown).
20+
- `docs/` always holds the **unreleased** docs ("0.3.0-RC (dev)" in the version dropdown).
2121

2222
## Appearance
2323

2424
The theme follows the design tokens of [feascript.com](https://feascript.com): cream "engineering paper" with a blueprint grid, charcoal ink, gold accent, a floating pill navbar, always-dark code blocks, and Roboto / Roboto Mono, with a matching dark mode. The footer uses the website's footer color (`#f6efd9`, `#222222` in dark mode). Colors and component styling live in `src/css/custom.css`; fonts and the code theme are set in `docusaurus.config.js`.
2525

26+
The navbar's GitHub pill matches the website and fetches the FEAScript-core star count from the public GitHub API in the browser. If the request fails, the link remains usable without a count and the error is logged to the browser console.
27+
2628
## Versioning
2729

2830
When a new FEAScript-core version is released, snapshot the current docs:
@@ -33,6 +35,8 @@ npm run version -- 0.3.0
3335

3436
This copies `docs/` to `versioned_docs/version-0.3.0/`, the sidebar to `versioned_sidebars/`, and records the version in `versions.json`. Released docs are then available at `docs.feascript.com/0.3.0/...` and appear in the version dropdown.
3537

38+
Versions appear inside that dropdown, not as separate links across the navbar. The space between the logo and the right-hand controls is flexible layout spacing.
39+
3640
After the first release, edit `docusaurus.config.js`: remove `lastVersion: "current"` so the newest released version becomes the default (unversioned URLs). Fixes to an old version are made directly in its `versioned_docs/version-x.y.z/` folder.
3741

3842
## Deployment

‎docusaurus.config.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const config = {
4848
// "current" holds the unreleased docs; released versions are snapshots (see README)
4949
lastVersion: "current",
5050
versions: {
51-
current: { label: "Next (0.3.0-RC)" },
51+
current: { label: "0.3.0-RC (dev)" },
5252
},
5353
},
5454
blog: false,
@@ -97,12 +97,9 @@ const config = {
9797
navbar: {
9898
items: [
9999
{ type: "docsVersionDropdown", position: "right" },
100-
{ href: "https://feascript.com", label: "Website", position: "right" },
101100
{
102-
type: "html",
101+
type: "custom-github",
103102
position: "right",
104-
value:
105-
'<a class="nav-icon" href="https://github.com/FEAScript/FEAScript-core" target="_blank" rel="noopener noreferrer" aria-label="FEAScript on GitHub" title="FEAScript on GitHub"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a>',
106103
},
107104
],
108105
},
@@ -113,7 +110,7 @@ const config = {
113110
title: "FEAScript",
114111
items: [
115112
{ label: "Website", href: "https://feascript.com" },
116-
{ label: "FEAScript Studio", href: "https://studio.feascript.com" },
113+
{ label: "FEAScript Studio", href: "https://feascript.com/studio.html" },
117114
{ label: "Blog", href: "https://blog.feascript.com" },
118115
],
119116
},

‎src/css/custom.css‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,22 @@ body {
255255
height: 1rem;
256256
}
257257

258+
.nav-github {
259+
width: auto;
260+
padding: 0 0.85rem;
261+
text-decoration: none;
262+
}
263+
264+
.nav-github:hover {
265+
text-decoration: none;
266+
}
267+
268+
.nav-github-stars {
269+
font-size: 0.8125rem;
270+
font-weight: 500;
271+
letter-spacing: 0.02em;
272+
}
273+
258274
.theme-toggle {
259275
position: relative;
260276
flex-direction: row-reverse;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import ComponentTypes from "@theme-original/NavbarItem/ComponentTypes";
2+
import GitHubNavbarItem from "./GitHubNavbarItem";
3+
4+
export default {
5+
...ComponentTypes,
6+
"custom-github": GitHubNavbarItem,
7+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { useEffect, useState } from "react";
2+
3+
export default function GitHubNavbarItem({ mobile = false }) {
4+
const [stars, setStars] = useState(null);
5+
6+
useEffect(() => {
7+
const controller = new AbortController();
8+
9+
async function loadStars() {
10+
try {
11+
const response = await fetch("https://api.github.com/repos/FEAScript/FEAScript-core", {
12+
signal: controller.signal,
13+
});
14+
if (!response.ok) {
15+
throw new Error(`GitHub API returned ${response.status}`);
16+
}
17+
const data = await response.json();
18+
if (!Number.isInteger(data.stargazers_count) || data.stargazers_count < 0) {
19+
throw new Error("GitHub API returned an invalid star count");
20+
}
21+
setStars(data.stargazers_count);
22+
} catch (error) {
23+
if (!controller.signal.aborted) {
24+
console.error("Error fetching GitHub stars:", error);
25+
}
26+
}
27+
}
28+
29+
loadStars();
30+
return () => controller.abort();
31+
}, []);
32+
33+
return (
34+
<div className={mobile ? "menu__list-item" : "navbar__item"}>
35+
<a
36+
className="nav-icon nav-github"
37+
href="https://github.com/FEAScript/FEAScript-core"
38+
target="_blank"
39+
rel="noopener noreferrer"
40+
aria-label="FEAScript on GitHub"
41+
title="FEAScript on GitHub"
42+
>
43+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
44+
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
45+
</svg>
46+
<span className="nav-github-stars">{stars === null ? "" : `\u2605 ${stars}`}</span>
47+
</a>
48+
</div>
49+
);
50+
}

0 commit comments

Comments
 (0)