A Metalsmith plugin to fetch GitHub profile information as global metadata.
npm install --save metalsmith-github-profileconst Metalsmith = require('metalsmith');
const githubProfile = require('metalsmith-github-profile');
Metalsmith(__dirname)
.use(githubProfile({
username: "<your-username-here>"
// additional options
}))
.build((err) => {
if (err) {
throw err;
}
});This plugin adds a metadata field named github.profile to the global metadata which can be used with templating engines, such as with handlebars:
The following metadata is available from the GitHub public API:
github.profile.user(Object)github.profile.repos(Object[])
Type: string
The GitHub username to fetch information for.
Type: {username: string, token: string}
A GitHub username and OAuth token (including personal access tokens) to use for API requests to get around rate limits.
You can source the token from environment variables like this:
githubProfile({
username: "emmercm",
authorization: {
username: "emmercm",
token: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
}
})Type: number Default: 5000
Timeout in milliseconds for API requests to GitHub.
Type: number Default: 3
Number of times to retry GitHub API requests.
Type: number[] Default: [0, 408, 500, 502, 503, 504]
A list of HTTP status codes to retry GitHub API requests on.