Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.
/ hoast-transform Public archive

Hoast module used to transform the content of files based on the extension.

License

Notifications You must be signed in to change notification settings

hoast/hoast-transform

Repository files navigation

npm package @latest npm package @next

Travis-ci status CodeCov coverage

License agreement Open issues on GitHub

hoast-transform

Transform the content of files based on the extension.

As the name suggest this is a hoast module. The module has been based of metalsmith-in-place.

Usage

Install hoast-transform using npm.

$ npm install hoast-transform

Parameters

  • options: Options given to the JSTransformer.
    • Type: Object
      • Default: {}
  • patterns: Glob patterns to match file paths with. If the engine function is set it will only give the function any files matching the pattern.
    • Type: String or Array of strings
      • Required: no
  • patternOptions: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.
    • Type: Object
    • Default: {}
  • patternOptions.all: This options is added to patternOptions, and determines whether all patterns need to match instead of only one.
    • Type: Boolean
    • Default: false

Example

CLI

{
  "modules": {
    "read": {},
    "hoast-transform": {
      "patterns": "*.md"
 	  }
  }
}

Script

const Hoast = require(`hoast`);
const read = Hoast.read,
      transform = require(`hoast-transform`);

Hoast(__dirname)
  .use(read())
  .use(transform({
    patterns: `*.md`
  }))
  .process();

In the examples the markdown files will be transformed to HTML.

Troubleshooting

If you are having problems with the module please enable debugging to have a closer look.

File not valid for processing.

  • The file is not utf-8 encoded.
  • The file path does not match any of the patterns.

No valid transformer found for extension .

  • Check if the JSTransformer associated with the extension is installed.