AcyOrt is used by default as a global CLI mode
But it is also supported as a node module. This following is a usage example
const acyort = require('acyort')
const config = {
base: __dirname, // specify the base directory
template: 'ccc45', // specify the template name
language: 'en', // language
root: '/', // website root directory
timezone: 'UTC', // time zone
public: '/' // file output root directory (relative to the base directory)
url: 'https://acyort.com', // website URL
}
const ctx = acyort(config) // at this point `ctx` can access the APIs provided by AcyOrt
So when should I use it as CLI and when can I use it as a node module?
In fact, both methods are similar. If your application already exists and you just want to borrow some of AcyOrt's capabilities, you can use it as node plugin
Others still recommend using CLI, by filling some configuration, use some plugins to generate the website.
AcyOrt built-in numbers of APIs
Use fs-extra
const { fs } = acyort
const { copySync, removeSync } = fs
Get AcyOrt version
const { version } = acyort
Get the configuration information from config.yml, and get some extra path information, etc
const config = acyort.config.get() // get all config
/*
{
url: 'https://acyort.com',
template: 'ccc45',
scripts: [ 'script.js' ],
plugins: [],
public: '/',
timezone: 'Asia/Shanghai',
language: 'en',
root: '/',
base: '/Users/am0200/Documents/github/acyort/assets'
}
*/
const url = acyort.config.get('url') // single config
acyort.config.set('version', acyort.version) // add config
Display information, use signale
const { logger } = acyort
logger.info('info')
logger.error('error')
// custom supports https://github.com/klaussinani/signale#custom-loggers
const option = { ... }
const custom = logger(option)
custom.remind('Improve documentation.')
Built-in support for swig
, markdown
, yaml
renders, supports custom renderers, check renderer for more
const { renderer } = acyort
renderer.render('swig', { title: 'swig' })
renderer.renderFile('swig', 'html path', { title: 'swig' })
For customize CLI commands, check cli for more
const { cli } = acyort
Use for data sharing, check store for more
const { store } = acyort
You can freely control the running, check wordflow for more
const { workflow } = acyort
Helper functions can be easily used in templates, and you can customize helper functions for template using, check helper for more
const { helper } = acyort
Provides some tool/util functions for plugin use, check util for more
const { util } = acyort
Provides hooks
for some interaction between plugins, check hooks for more
const { hooks } = acyort