1.0.1 • Published 4 years ago

metalsmith-projects v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

metalsmith-projects

Build Status Greenkeeper badge

A Metalsmith plugin for adding metadata for projects (think portfolio content) from GitHub or filesystem (through metalsmith-collections) that can be looped over for creating a portfolio of work.

Installation

$ npm install metalsmith-projects

Usage

There are currently two sources from which projects can be retrieved from:

  • GitHub: retrieves metadata on all public non-fork repositories owned by the provided username, plus any specific additional repositories.
  • collection: retrieves metadata from the front-matter of files under a specified collection.

All sources add objects to the the metadata property projects of the form:

PropertyType
nameString
ownerString
fullNameString
descriptionString
stargazerCountNumber
lastUpdatedDate
languagesString[]
urlString

Multiple sources can be used simultaneously in the same call to metalsmith-projects.

Source: GitHub

const projects = require("metalsmith-projects").default;

metalsmith.use(projects({
  github: {
    authToken: "<githubOAuth2Token>", // optional (see note below)
    username: "AshleyWright",
    additionalRepos: ["<owner>/<repoName>", ...],  // optional
    exclude: ["<owner>/<repoName>", ...] // optional
  }
}))

Note: although an authToken is not required, absence of one incurs greater GitHub API rate limiting.

Source: collection

const collections = require("metalsmith-collections");
const projects = require("metalsmith-projects").default;

metalsmith.use(collections({
  <collectionName>: "<fileGlob>"
})).use(projects({
  collection: {
    name: "<collectionName>",
    defaultOwner: "<defaultOwner>"
  }
}))

The mapping of file front-matter to project metadata is as follows:

Project metadataFrontmatterDefault Value
nameprojectName or title"Unnamed"
ownerowneroptions.collection.defaultOwner
fullNameprojectFullName or title"Unnamed"
descriptionprojectDescription"" (the empty string)
stargazerCountstargazerCount0
lastUpdatedlastUpdated or datePublishedundefined
languagesprojectLanguages[]
urlurlmetadata.site.url + fileMetadata.path

MIT © Ashley Wright