-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# contributors | ||
|
||
The `contributors` generator generates an image of contributors using [contrib.rocks](https://contrib.rocks/) service plus additional data about authors and license. | ||
|
||
<!-- automd:example generator=contributors author=pi0 license=MIT --> | ||
|
||
## Example | ||
|
||
### Input | ||
|
||
<!-- automd:contributors author=pi0 license=MIT --> | ||
<!-- /automd --> | ||
|
||
### Output | ||
|
||
<!-- automd:contributors author=pi0 license=MIT --> | ||
|
||
Published under the [MIT](https://github.com/unjs/automd/blob/main/LICENSE) license. | ||
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/automd/graphs/contributors) 💛 | ||
<br><br> | ||
<a href="https://github.com/unjs/automd/graphs/contributors"> | ||
<img src="https://contrib.rocks/image?repo=unjs/automd" /> | ||
</a> | ||
|
||
<!-- /automd --> | ||
|
||
<!-- /automd --> | ||
|
||
## Arguments | ||
|
||
- `github`: Github repository name (by default tries to read from `package.json`) | ||
- `max`: Max contributor count (100 by default) | ||
- `anon` Include anonymous users (false by default) | ||
- `author`: Comma separated list of github usersnames. | ||
- `license`: Name of license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { getPkg } from "../_utils"; | ||
import { defineGenerator } from "../generator"; | ||
|
||
export const contributors = defineGenerator({ | ||
name: "contributors", | ||
async generate({ config, args }) { | ||
const { github } = await getPkg(config.dir, args); | ||
|
||
if (!github) { | ||
throw new Error("`github` is required!"); | ||
} | ||
|
||
const lines: string[] = []; | ||
|
||
// License | ||
if (typeof args.license === "string") { | ||
lines.push( | ||
`Published under the [${args.license.toUpperCase()}](https://github.com/${github}/blob/main/LICENSE) license.`, | ||
); | ||
} | ||
|
||
// Made by | ||
let madeBy = `[community](https://github.com/${github}/graphs/contributors) 💛`; | ||
if (typeof args.author === "string") { | ||
const authors = args.author | ||
.split(",") | ||
.map((author) => author.trim()) | ||
.map((user) => `[@${user}](https://github.com/${user})`) | ||
.join(", "); | ||
if (authors.length > 0) { | ||
madeBy = `${authors} and ${madeBy}`; | ||
} | ||
} | ||
lines.push(`Made by ${madeBy}`); | ||
|
||
// Contributors | ||
const params = [["repo", github]]; | ||
if (args.max) { | ||
params.push(["max", args.max]); | ||
} | ||
if (args.anon) { | ||
params.push(["anon", args.anon]); | ||
} | ||
const paramsStr = params.map(([k, v]) => `${k}=${v}`).join("&"); | ||
lines.push( | ||
`<br><br>`, | ||
`<a href="https://github.com/${github}/graphs/contributors">`, | ||
`<img src="https://contrib.rocks/image?${paramsStr}" />`, | ||
`</a>`, | ||
); | ||
|
||
return { | ||
contents: lines.join("\n"), | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters