This package has been deprecated

Author message:

This package is deprecated. Use the 'sanity-template' package instead

sanity-template-tools

1.0.0 • Public • Published

sanity-template

Sanity template developer tools, documentation and specification.

npm install sanity-template-tools --save-dev

npm version

sanity-template-tools exposes both a command line interface and a Node.js API.

Specfication

WARNING: Not ready for public consumption

CLI

# Build template files from `template/` to `build/`
npx sanity-template build --template-values values.json

# The same, but in watch mode
npx sanity-template watch --template-values values.json

This will copy files from the template directory into the build (which should be gitignored). The files in the build directory will have template variables replaced (<#<varName>#>).

Node.js API

build

The build method returns a Promise instance:

const { build } = require("sanity-template-tools");

build({
  basedir: "path/to/basedir",
  templateValuesPath: "template-values.json"
})
  .then(() => console.log("successfully built"))
  .catch(err => console.error(err));

watch

The watch method returns an RxJS Observable instance:

const { watch } = require("sanity-template-tools");

watch({
  basedir: "path/to/basedir",
  templateValuesPath: "template-values.json"
}).subscribe({
  next: ({ type, file }) => console.log(`${type}: ${file}`),
  error: err => console.error(err)
});

TODO

  • [x] Watch mode
  • [ ] Manifest validation
  • [ ] Validate existence of dir paths (sourceDir and targetDir)
  • [ ] Make params for dir paths (sourceDir and targetDir)

License

MIT © Sanity.io

Readme

Keywords

none

Package Sidebar

Install

npm i sanity-template-tools

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

36 kB

Total Files

33

Last publish

Collaborators

  • mariuslundgard