scripts/lib/generators/post.js
/**
   * Adding post pagination API data
   * @returns Array
   */
Adding post pagination API data
@returns Array
Adding post pagination API data @returns Array
addPaginationPost(data) {
    if (this.count <= 0) return data
    const pageJson = []
    const length = this.count()
    const pageSize = 12
    const pageCount = Math.ceil(length / pageSize)
    const postData = this.data.map(postListMapper)
    for (let i = 0; i < length; i += pageSize) {
      pageJson.push({
        path: 'api/posts/' + Math.ceil((i + 1) / pageSize) + '.json',
        data: JSON.stringify({
          total: length,
          pageSize: pageSize,
          pageCount: pageCount,
          data: postData.slice(i, i + pageSize)
        })
      })
    }
    data = data.concat(pageJson)
    return data
  }
addPaginationPost ( data ) { if ( this . count <= 0 ) return data const pageJson = [ ] const length = this . count ( ) const pageSize = 12 const pageCount = Math . ceil ( length / pageSize ) const postData = this . data . map ( postListMapper ) for ( let i = 0 ; i < length ; i += pageSize ) { pageJson . push ( { path : 'api/posts/' + Math . ceil ( ( i + 1 ) / pageSize ) + '.json' , data : JSON . stringify ( { total : length , pageSize : pageSize , pageCount : pageCount , data : postData . slice ( i , i + pageSize ) } ) } ) } data = data . concat ( pageJson ) return data }
Adding post pagination API data
 @returns Array
Adding post pagination API data @returns Array