|
1 | | -# OpenSource.Win — For Our Shared Future |
| 1 | +# OpenSource.Win |
2 | 2 |
|
3 | | -Static site for OpenSource.Win Manifesto with hacker aesthetic and bilingual EN/zh toggle. |
4 | | - |
| 3 | +[English](README.md) | [简体中文](README.zh-CN.md) | [繁體中文](README.zh-TW.md) |
| 4 | + |
| 5 | +The source for [opensource.win](https://opensource.win): an Astro monorepo for the OpenSource.Win manifesto and the China Open Source HeroRank. |
| 6 | + |
| 7 | +## What is here |
| 8 | + |
| 9 | +- `apps/www` — the OpenSource.Win manifesto landing site. |
| 10 | +- `apps/ossheroes` — the China Open Source HeroRank site, including Astro Content Collections for developer profiles and annual rankings. |
| 11 | +- `packages/ui` — shared UI components, design tokens, and SEO exports used by both sites. |
| 12 | + |
| 13 | +Both applications are static-first Astro sites. React is used only for selective interactive islands, and Tailwind CSS provides styling. The published site uses clean, file-based routes rather than a hash-routed SPA. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +- Node.js 20 (the GitHub Actions workflow uses Node 20) |
| 18 | +- pnpm 9.15.0 (declared by the root `packageManager` field) |
| 19 | + |
| 20 | +```bash |
| 21 | +corepack enable |
| 22 | +pnpm --version |
| 23 | +``` |
| 24 | + |
| 25 | +## Install, develop, build, and preview |
| 26 | + |
| 27 | +```bash |
| 28 | +pnpm install --frozen-lockfile |
| 29 | +pnpm dev # manifesto app |
| 30 | +pnpm --filter ossheroes dev # HeroRank app |
| 31 | +pnpm build |
| 32 | +pnpm --filter www preview |
| 33 | +pnpm --filter ossheroes preview |
| 34 | +``` |
| 35 | + |
| 36 | +## Verify HeroRank output |
| 37 | + |
| 38 | +The checks read built output; `verify:seo` also reads `apps/www/dist` for the generated sitemap and `llms.txt`. |
| 39 | + |
| 40 | +```bash |
| 41 | +pnpm build |
| 42 | +pnpm --filter ossheroes verify:urls |
| 43 | +pnpm --filter ossheroes verify:seo |
| 44 | +``` |
| 45 | + |
| 46 | +`verify:urls` checks canonical HeroRank pages and static compatibility redirects. `verify:seo` checks canonical and Open Graph URLs, sampled profile JSON-LD, and the root sitemap and `llms.txt`. |
| 47 | + |
| 48 | +## Public routes |
| 49 | + |
| 50 | +| Route | Purpose | |
| 51 | +| --- | --- | |
| 52 | +| `/` | OpenSource.Win manifesto landing page | |
| 53 | +| `/heroes/` | HeroRank home page | |
| 54 | +| `/hero/<login>/` | Developer profile | |
| 55 | +| `/heroes/ranking-<year>/` | Annual ranking | |
| 56 | + |
| 57 | +Legacy `/ossheroes/`, `/ossheroes/<login>/`, and `/ossheroes/ranking-<year>/` paths are static redirect pages that preserve query strings and fragments while directing visitors to the canonical routes. |
| 58 | + |
| 59 | +## Project structure |
| 60 | + |
| 61 | +```text |
| 62 | +apps/ |
| 63 | + www/ # manifesto landing site |
| 64 | + ossheroes/ # HeroRank app, content, data, and checks |
| 65 | + src/content/heroes/<login>/index.md |
| 66 | + src/data/rankingList.json |
| 67 | + script/ # Node.js ranking/content maintenance scripts |
| 68 | + scripts/ # built-output URL and SEO verification scripts |
| 69 | +packages/ |
| 70 | + ui/ # shared UI, tokens, and SEO exports |
| 71 | +.github/workflows/ |
| 72 | + gh-pages.yml # build, verify, merge, and deploy workflow |
| 73 | +``` |
| 74 | + |
| 75 | +## HeroRank content and data |
| 76 | + |
| 77 | +Developer profiles are Markdown entries in the `heroes` Content Collection at `apps/ossheroes/src/content/heroes/<login>/index.md`. The directory name and `slug` should be the developer's GitHub login. |
| 78 | + |
| 79 | +```md |
| 80 | +--- |
| 81 | +slug: foo |
| 82 | +name: Foo |
| 83 | +description: Developer location |
| 84 | +github_id: 123456 |
| 85 | +github_avatar: https://avatars.githubusercontent.com/u/123456?v=4 |
| 86 | +--- |
| 87 | + |
| 88 | +Profile text in Markdown. |
| 89 | +``` |
| 90 | + |
| 91 | +`description` is currently displayed as the developer location. An optional local avatar can sit beside `index.md` and be referenced as `avatar: avatar.png`. Keep contributions focused on the relevant profile; profile and ranking changes are reviewed through pull requests. |
| 92 | + |
| 93 | +Annual rankings are generated from `apps/ossheroes/src/data/rankingList.json`. The Node.js scripts in `apps/ossheroes/script/` support the existing maintenance flow: `sync_xlab.js` refreshes a year from the X-lab source, `update_year_user.js` or `update_all_user.js` enriches GitHub user data (and may require `GITHUB_TOKEN` to avoid API limits), and `front-matter.js` writes those fields into profile Markdown. `enrich-contributions.js` can add primary-contribution repository links to otherwise empty profiles and create pages for its configured new logins; it also uses the GitHub REST API and should be run with `GITHUB_TOKEN`. These scripts determine the target year from the current date where applicable; inspect them and review their data changes before running. When adding a year, also add its compatibility placeholder under `src/content/heroes/opensource-ranking/` as described in [`apps/ossheroes/DEVELOP.md`](apps/ossheroes/DEVELOP.md). |
| 94 | + |
| 95 | +## Deployment |
| 96 | + |
| 97 | +GitHub Actions runs on pushes to `main` and when the `Monthly Script Runner` workflow completes. It installs locked pnpm dependencies, builds both apps, runs the HeroRank URL and SEO checks, merges `apps/www/dist` and `apps/ossheroes/dist` into a single `dist/`, and deploys that directory to the `gh-pages` branch for `opensource.win`. |
| 98 | + |
| 99 | +For another branch, run the local build and checks above, then open a pull request to `main`; deployment follows the merged push. The workflow expects both apps to emit route files at the root of their own output directories, so do not add a site-wide Astro `base` path. |
| 100 | + |
| 101 | +## Contributing |
| 102 | + |
| 103 | +Use pnpm from the repository root, keep changes scoped, and run the relevant build and checks before opening a pull request. Do not commit generated `dist` output unless a change explicitly requires it. For HeroRank profile submissions, change only the applicable content and assets and provide accurate, reviewable information. |
0 commit comments