Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Builds the site from `main` and publishes the static export to `gh-pages`.
#
# Runs on every push to main, every day (to pick up new releases, commits and
# documentation of the napi-bindings repositories), on demand, and when another
# repository sends a `repository_dispatch` event of type `napi-bindings-updated`:
#
# gh api repos/napi-bindings/website/dispatches -f event_type=napi-bindings-updated
#
# Pull requests are built and checked but never deployed.
name: Build and deploy

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "17 4 * * *"
workflow_dispatch:
repository_dispatch:
types: [napi-bindings-updated]

permissions:
contents: write

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- run: npm ci

- name: Synchronise data from GitHub, npm and nodejs/node
run: npm run sync
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: npm run typecheck
- run: npm run lint

- name: Build the static export
run: npm run build
env:
# Empty with the custom domain; set to /website to serve from
# https://napi-bindings.github.io/website instead.
NEXT_PUBLIC_BASE_PATH: ""

- uses: actions/upload-artifact@v4
with:
name: site
path: out
include-hidden-files: true
retention-days: 7

deploy:
needs: build
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: site
path: out

- name: Publish to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./out
cname: www.napi-bindings.dev
# gh-pages only holds build output: keep it to a single commit.
force_orphan: true
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_message: "deploy: ${{ github.sha }}"
84 changes: 32 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,41 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# Bower dependency directory (https://bower.io/)
bower_components
# testing
/coverage

# node-waf configuration
.lock-wscript
# next.js
/.next/
/out/

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# production
/build

# Dependency directories
node_modules/
jspm_packages/
# misc
.DS_Store
*.pem

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# Yarn Integrity file
.yarn-integrity
# env files (can opt-in for committing if needed)
.env*

# dotenv environment variables file
.env
# vercel
.vercel

# next.js build output
.next
# typescript
*.tsbuildinfo
next-env.d.ts
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- BEGIN:nextjs-agent-rules -->

## This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.

This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.

<!-- END:nextjs-agent-rules -->
100 changes: 99 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,99 @@
# website
# napi-bindings.dev

Source of [www.napi-bindings.dev](https://www.napi-bindings.dev): the reference hub for
[Node-API](https://nodejs.org/docs/latest/api/n-api.html) and the home of the
[napi-bindings](https://github.com/napi-bindings) projects.

- **Source**: branch `main` (this branch).
- **Published site**: branch `gh-pages`, written only by GitHub Actions.

## What the site contains

| Route | Content | Source |
| --- | --- | --- |
| `/` | Home: Node-API in short, projects, latest releases, ecosystem | all of the below |
| `/node-api/` | Overview of Node-API: loading, headers, versions, core concepts | written here |
| `/node-api/docs/<section>/` | Each section of the official Node-API guide | `nodejs/node` `doc/api/n-api.md` |
| `/node-api/reference/` | Searchable index of every function, type and callback | `n-api.md` + `js_native_api.h` / `node_api.h` |
| `/node-api/reference/<symbol>/` | One page per API: signature, parameters, versions, header | `n-api.md` |
| `/node-api/versions/` | Version matrix and the APIs added by each version | `n-api.md` |
| `/projects/` | Catalog with filters by category and language | `src/config/projects.ts` + GitHub |
| `/projects/<slug>/` | README, install snippets, npm, repository facts | repository |
| `/projects/<slug>/docs/…` | Every Markdown document of the repository | repository |
| `/projects/<slug>/releases/` | Release notes (CHANGELOG section as fallback) | GitHub releases |
| `/projects/<slug>/changelog/` | CHANGELOG.md | repository |
| `/projects/<slug>/activity/`, `/activity/` | Commits and releases, per project and organization-wide | repository + releases |
| `/ecosystem/` | Language bindings, runtimes, build tools, talks | `nodejs/abi-stable-node` |
| `/search-index.json` | Index used by the ⌘K search palette | generated |

## Stack

- [Next.js](https://nextjs.org) App Router with `output: "export"`: a static site, no server.
- React 19, TypeScript (`strict`), Tailwind CSS v4.
- [shadcn/ui](https://ui.shadcn.com) components in the **base-nova** style, built on
[Base UI](https://base-ui.com) (`src/components/ui`, configured in `components.json`).
- Markdown rendered at build time with unified/remark/rehype; code highlighted with
[Shiki](https://shiki.style); Mermaid diagrams rendered in the browser on the pages that have them.
- Data validated with [Zod](https://zod.dev) (`src/lib/data-schema.ts`).

## How the data is kept up to date

`npm run sync` (`scripts/sync-data.ts`) writes `src/generated/*.json`:

1. **Projects** (`src/config/projects.ts`): metadata, languages and releases from the GitHub API;
README, CHANGELOG, all Markdown documents and the last 40 commits from a shallow `git clone`;
versions and downloads from npm.
2. **Node-API reference**: `doc/api/n-api.md` and the headers from `nodejs/node`, parsed into
sections and symbols.
3. **Ecosystem**: the binding and runtime lists and the talks from `nodejs/abi-stable-node`.

Every source is optional: when one fails, the previous value in `src/generated/` is kept
(then `data/seed.json`), so the build never breaks because of a network problem. The generated
files are committed, so `npm run build` also works offline.

The workflow `.github/workflows/deploy.yml` runs the sync and the build on every push to
`main`, every day, on demand, and when a repository of the organization sends a
`repository_dispatch` event:

```sh
gh api repos/napi-bindings/website/dispatches -f event_type=napi-bindings-updated
```

## Development

Requires Node.js 22.18 or later.

```sh
npm install
npm run dev # http://localhost:3000
npm run sync # refresh src/generated/ (set GITHUB_TOKEN to avoid rate limits)
npm run typecheck
npm run lint
npm run build # static export in out/
npm start # serve out/ locally
```

### Adding a project

Add an entry to `PROJECTS` in `src/config/projects.ts` (name, category, tagline, install
snippets, related projects), then run `npm run sync`. Pages, search, sitemap and activity
feed pick it up automatically.

### Adding UI components

```sh
npx shadcn@latest add <component>
```

## Deployment

GitHub Pages must publish from the **`gh-pages`** branch (Settings → Pages → Deploy from a
branch → `gh-pages` / root). The workflow writes the `CNAME` file for `www.napi-bindings.dev`
and a `.nojekyll` file so that `_next/` is served.

To serve the site from `https://napi-bindings.github.io/website` instead of the custom domain,
set `NEXT_PUBLIC_BASE_PATH: /website` in the workflow and remove the `cname` input.

## License

Code: [Apache-2.0](LICENSE). Node-API documentation content: © Node.js contributors, MIT license.
22 changes: 22 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "base-nova",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {}
}
Loading
Loading