@ewizardjs/banner-structure-api
v1.2.0
Published
Banner structure api
Keywords
Readme
BANNER STRUCTURE API
Banner structure api is a set of methods that will simplify working with banner array and banners structure.
Install banner-structure-api with npm
npm i @ewizardjs/banner-structure-apiUsage/Examples
In your ".ts"/".js" files:
import {
getBanners,
makeStructure,
} from '@ewizardjs/banner-structure-api';
const structure = readJson('./structure.json');
const bannersArray = getBanners(structure);
const structureJson = makeStructure(bannersArray); Available Interfaces / Types / etc
| Name | Fields | Description | |:------------|:------------------------------------|:-------------------------------| | Banner | id, name, size, template, thumbnail | The main fields of each banner | | BannerSize | width, height, dpr | Dimensions of each banner | | BannersJson | banners | Json file format with banners |
Description of banner fields
| Name | Description | Required field in json | |:----------|:---------------------------------|:-----------------------| | id | Banner id | Yes | | name | Banner name | Yes | | size | Banner size. Has type BannerSize | Yes | | template | Path to the banner template | No | | thumbnail | Path to the banner thumbnail | No | | width | Banner width | Yes | | height | Banner height | Yes | | dpr | Device pixel ratio | Yes |
API Reference
| Method | Arguments | Execution result | Description |
|:----------------|:---------------------------|:----------------------------------|:------------------------------------------|
| getBanners | bannersJson[, options] | An array of Banner type objects | Get information about all banners |
| makeStructure | bannersArray | JSON of type BannersJson | Get new structure json from banners array |
Arguments of the methods
| Name | Description |
|:-----------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| bannersJson | structure.json file content |
| options | A set of options. May include systemSettings and callback fields |
| bannersArray | An array of banners |
| systemSettings | Fragment of the default paths object. Necessary for forming paths to the template and thumbnails in the banner type structures. Can be obtained from the "@ewizardjs/system-settings" module. |
