node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

tm-content-generator

TM Content Generator

A content generator to be used in conjunction with Pravda

Build Status codecov

This is a content generator to be used with PRAVDA, which is a GraphQL API that interfaces with the Escenic's WebService.

Example usage

Below is a non-ES6 example that generates a news article:

'use strict';
 
var ContentGenerator = require('tm-content-generator').default;
var contentGenerator = new ContentGenerator();
 
// generate an article with only 1 picture inline relation and 1 html inline relation
var articleMeta = contentGenerator.generateArticle(
    { sectionId: 70, publication: 'mirror' },
    { picture: [1,2,3], html: [4,5] },
    { pictureRel: [], teaserRel: [], inlineRelations: ['picture','html'] },
    { min: 1, max: 1 }
);

Below is an ES6+ example that generates a news article:

import ContentGenerator from 'tm-content-generator';
const contentGenerator = ContentGenerator();
 
// generate an article with only 1 picture inline relation and 1 html inline relation
const articleMeta = contentGenerator.generateArticle(
    { sectionId: 70, publication: 'mirror' },
    { picture: [1,2,3], html: [4,5] },
    { pictureRel: [], teaserRel: [], inlineRelations: ['picture','html'] },
    { min: 1, max: 1 }
);