An open API service indexing awesome lists of open source software.

https://github.com/cssnr/vitepress-plugin-contributors

VitePress Plugin to easily display GitHub contributors and automatically updated on every install/deploy
https://github.com/cssnr/vitepress-plugin-contributors

vitepress-plugin

Last synced: 2 months ago
JSON representation

VitePress Plugin to easily display GitHub contributors and automatically updated on every install/deploy

Awesome Lists containing this project

README

          

[![NPM Version](https://img.shields.io/npm/v/%40cssnr%2Fvitepress-plugin-contributors?logo=npm)](https://www.npmjs.com/package/@cssnr/vitepress-plugin-contributors)
[![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/vitepress-plugin-contributors?logo=github)](https://github.com/cssnr/vitepress-plugin-contributors/releases)
[![NPM Downloads](https://img.shields.io/npm/dm/%40cssnr%2Fvitepress-plugin-contributors?logo=npm)](https://npm-stat.com/charts.html?package=%40cssnr%2Fvitepress-plugin-contributors)
[![Bundlephobia Size](https://img.shields.io/bundlephobia/min/%40cssnr%2Fvitepress-plugin-contributors?logo=bookstack&logoColor=white)](https://bundlephobia.com/package/@cssnr/vitepress-plugin-contributors)
[![Deployments NPM](https://img.shields.io/github/deployments/cssnr/vitepress-plugin-contributors/npm?logo=npm&label=deploy)](https://github.com/cssnr/vitepress-plugin-contributors/deployments/npm)
[![Deployments Docs](https://img.shields.io/github/deployments/cssnr/vitepress-plugin-contributors/docs?logo=vitepress&logoColor=white&label=docs)](https://github.com/cssnr/vitepress-plugin-contributors/deployments/docs)
[![Workflow Release](https://img.shields.io/github/actions/workflow/status/cssnr/vitepress-plugin-contributors/release.yaml?logo=norton&logoColor=white&label=release)](https://github.com/cssnr/vitepress-plugin-contributors/actions/workflows/release.yaml)
[![Workflow Lint](https://img.shields.io/github/actions/workflow/status/cssnr/vitepress-plugin-contributors/lint.yaml?logo=norton&logoColor=white&label=lint)](https://github.com/cssnr/vitepress-plugin-contributors/actions/workflows/lint.yaml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/vitepress-plugin-contributors?logo=listenhub&label=updated)](https://github.com/cssnr/vitepress-plugin-contributors/pulse)
[![GitHub Repo Size](https://img.shields.io/github/repo-size/cssnr/vitepress-plugin-contributors?logo=buffer&label=repo%20size)](https://github.com/cssnr/vitepress-plugin-contributors?tab=readme-ov-file#readme)
[![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/vitepress-plugin-contributors?logo=devbox)](https://github.com/cssnr/vitepress-plugin-contributors?tab=readme-ov-file#readme)
[![GitHub Contributors](https://img.shields.io/github/contributors-anon/cssnr/vitepress-plugin-contributors?logo=southwestairlines)](https://github.com/cssnr/vitepress-plugin-contributors/graphs/contributors)
[![GitHub Issues](https://img.shields.io/github/issues/cssnr/vitepress-plugin-contributors?logo=codeforces&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/issues)
[![GitHub Discussions](https://img.shields.io/github/discussions/cssnr/vitepress-plugin-contributors?logo=theconversation)](https://github.com/cssnr/vitepress-plugin-contributors/discussions)
[![GitHub Forks](https://img.shields.io/github/forks/cssnr/vitepress-plugin-contributors?style=flat&logo=forgejo&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/forks)
[![GitHub Repo Stars](https://img.shields.io/github/stars/cssnr/vitepress-plugin-contributors?style=flat&logo=gleam&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/stargazers)
[![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=apachespark&logoColor=white&label=org%20stars)](https://cssnr.github.io/)
[![Discord](https://img.shields.io/discord/899171661457293343?logo=discord&logoColor=white&label=discord&color=7289da)](https://discord.gg/wXy6m2X8wY)
[![Ko-fi](https://img.shields.io/badge/Ko--fi-72a5f2?logo=kofi&label=support)](https://ko-fi.com/cssnr)

# VitePress Plugin Contributors


VitePress Plugin Contributors

- [Install](#Install)
- [Usage](#Usage)
- [Options](#Options)
- [Demos](#Demos)
- [Support](#Support)
- [Contributing](#Contributing)

A [VitePress](https://vitepress.dev/) Plugin to Easily generate, update and display repository Contributors.
Supports GitHub (including Enterprise) and Forgejo (Gitea, Codeberg, etc.).

This [package](https://www.npmjs.com/package/@cssnr/vitepress-plugin-contributors) includes two components that can be use together or individually.

1. [get-contributors](src/get-contributors.js) - script to generate the `contributors.json` file.
2. [Contributors.vue](src/Contributors.vue) - component to display the contributors in VitePress.

Also includes a detailed [Installation](#install) guide with available [Support](#support).

[![View Documentation](https://img.shields.io/badge/view_documentation-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://vitepress-contributors.cssnr.com/)

## Install

[![View Install Guide](https://img.shields.io/badge/view_install_guide-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://vitepress-contributors.cssnr.com/guides/get-started#install)

1. Install directly into your VitePress from [npmjs](https://www.npmjs.com/package/@cssnr/vitepress-plugin-contributors).

```shell
npm i @cssnr/vitepress-plugin-contributors
```

2. Add the [get-contributors](src/get-contributors.js) script to your `package.json`.

```json
{
"scripts": {
"get-contributors": "npx get-contributors user/repo",
"postinstall": "npm run get-contributors"
}
}
```

_If you don't add the `postinstall` script you need to add `get-contributors` to your build._

Click Here to View Usage - get-contributors

[![View Get Contributors Docs](https://img.shields.io/badge/view_get_contributors_docs-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://vitepress-contributors.cssnr.com/docs/get-contributors)

Show help: `npx get-contributors -h`

Basic usage, all contributors excluding bot users.

```shell
npx get-contributors user/repo
```

Limit to top 20 contributors, specify output file, and include bot users.

```shell
npx get-contributors user/repo -m 20 -f .vitepress/contributors.json -b
```

Only the `user/repo` is required. All other arguments are optional.

| Argument Flag | Default Value | Description of the Argument |
| :----------------- | :----------------------------- | :----------------------------------------- |
| `-f`/`--file` | `.vitepress/contributors.json` | Output file relative to project root |
| `-m`/`--max-users` | `0` | Max users to fetch, 0 is unlimited |
| `-b`/`--bots` | - | Include bot users in the results |
| `-e`/`--error` | - | Throw errors during generation |
| `-k`/`--keys` | `login,avatar_url` | Contributor keys to save to file |
| `-G`/`--github` | `https://api.github.com` | GitHub API URL (for Enterprise) |
| `-F`/`--forgejo` | - | Forgejo API URL (for Gitea/Codeberg) |

Note: This script makes 1 request to the GitHub API for every 100 contributors on the repository (or `max-users`).
Because of this if you have a lot of contributors (200+) running this back-to-back may hit
the [GitHub rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-primary-rate-limits) for unauthenticated requests, which is 60 requests per hour.
If this occurs the script will generate a partial or empty contributors so development can continue.

**This does not affect GitHub Action runs which are authenticated with the `GTIHUB_TOKEN`.**

---

3. Add the `contributors.json` file location to your `.gitignore`.

```txt
.vitepress/contributors.json
```

4. Generate the `contributors.json` file.

```shell
npm run get-contributors
```

Alternatively, if you did not add the `get-contributors` script from step #2.

```shell
npx get-contributors user/repo
```

5. Import the components in your `.vitepress/theme/index.js`.

```javascript
import DefaultTheme, { VPBadge } from 'vitepress/theme' // only if using VPBadge

import Contributors from '@cssnr/vitepress-plugin-contributors' // ADD this line
import '@cssnr/vitepress-plugin-contributors/style.css' // ADD this line

import contributors from '../contributors.json' // OPTIONAL - Global

export default {
...DefaultTheme,
enhanceApp({ app }) {
app.component('Badge', VPBadge) // only if using VPBadge
app.component('Contributors', Contributors) // ADD this line
app.config.globalProperties.$contributors = contributors // OPTIONAL - Global
},
}
```

`Global` - If you are unsure about this [usage](#usage), add these lines for simplicity.

`VPBadge` - Only required if you are using the VitePress [Badge](https://vitepress.dev/reference/default-theme-badge#badge).

More Details on the contributors.json path

Note, you may need to modify the `../contributors.json` import location to match your setup.
If your VitePress configuration directory is located at `.vitepress` then the default output
path of `.vitepress/contributors.json` will import from the relative path `../contributors.json`.

If you are not importing `contributors` as a Global, this path will be relative to the file you are importing it in.
See the [Usage](#usage) for more details.

---

6. Finally, use the [Contributors.vue](src/Contributors.vue) component in your markdown or component.

```markdown

```

See the [Usage](#usage) for more details...

## Usage

[![View Usage Guide](https://img.shields.io/badge/view_usage_guide-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://vitepress-contributors.cssnr.com/guides/get-started#usage)

To use, simply add the `` tag to your markdown file (or component).

If you added `contributors` as a global component, you only need the `` tag.

```markdown

```

Otherwise, import the `contributors.json` and add a `` tag.

```markdown

import contributors from '../.vitepress/contributors.json'

```

The `contributors.json` file is relative to the file you are importing it in.

See the [Options](#options) for more details...

## Options

[![View Contributors Docs](https://img.shields.io/badge/view_contributors_docs-blue?style=for-the-badge&logo=googledocs&logoColor=white)](https://vitepress-contributors.cssnr.com/docs/contributors)

Only the `:contributors` parameter is required, everything else is optional.

| Parameter | Default | Type | Description of the Parameter |
| :---------------- | :----------: | :----: | :----------------------------------------------------------------------------------------- |
| **:contributors** | **Required** | Array | `contributors.json` file import data |
| **max-users** | - | String | Max Number of users to display |
| **heading** | - | String | Optional Heading text |
| **size** | `64` | String | Size of Icons in pixels |
| **margin** | - | String | [CSS margin](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) string for container |

Example with all arguments.

```markdown

```

[![VitePress Contributors](https://raw.githubusercontent.com/smashedr/repo-images/refs/heads/master/vp-contributors/shots/contributors98.jpg)](https://github.com/cssnr/vitepress-plugin-contributors?tab=readme-ov-file#readme)

## Demos

The plugin is running on these pages:

- https://django-files.github.io/ and [/team](https://django-files.github.io/team)
- https://docker-deploy.cssnr.com/
- https://portainer-deploy.cssnr.com/

If you have a live demo, [let us know](#support) and we will post it here...

## Support

Logs can be found inspecting the page (Ctrl+Shift+I), clicking on the Console, and;
Firefox: toggling Debug logs, Chrome: toggling Verbose from levels dropdown.

If you run into any issues or need help getting started, please do one of the following:

- Report an Issue:
- Q&A Discussion:
- Request a Feature:
- Chat with us on Discord:

[![Features](https://img.shields.io/badge/features-brightgreen?style=for-the-badge&logo=rocket&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/issues/new?template=1-feature.yaml)
[![Issues](https://img.shields.io/badge/issues-red?style=for-the-badge&logo=southwestairlines&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/issues)
[![Discussions](https://img.shields.io/badge/discussions-blue?style=for-the-badge&logo=livechat&logoColor=white)](https://github.com/cssnr/vitepress-plugin-contributors/discussions)
[![Discord](https://img.shields.io/badge/discord-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/wXy6m2X8wY)

### More VitePress Plugins

- [SwiperJS](https://github.com/cssnr/vitepress-swiper) - Photo Gallery
- [Contributors](https://github.com/cssnr/vitepress-plugin-contributors) - GitHub Contributors
- [Copy Button](https://github.com/cssnr/vitepress-plugin-copybutton) - Copy Text Button

# Contributing

All contributions are welcome including [bug reports](https://github.com/cssnr/vitepress-plugin-contributors/issues), [feature requests](https://github.com/cssnr/vitepress-plugin-contributors/issues/new?template=1-feature.yaml), or pull requests.

For instructions on creating a PR for the [Package](https://www.npmjs.com/package/@cssnr/vitepress-plugin-contributors) or [Documentation](https://vitepress-contributors.cssnr.com/),
see the [CONTRIBUTING.md](#contributing-ov-file).

Please consider making a donation to support the development of this project and additional open source projects.

[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cssnr)

For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/)





Star History Chart