- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
// Config for `nuxt generate`
generate: {
dir: 'dist/lp/',
async routes ()
{
/*
* `models[]` must be an array of `template/page` elements.
* we get templates by scanning the local `pages/lp/` directory,
* and each model (sitewide, rmsitewide, sale, etc) will
* come from Airtable. The final array should look like
* [sbsr/sitewide, sbsr/sale, foo/sitewide, foo/sale, etc]
*/
const templates = fs.readdirSync(__dirname + '/pages/')
// Get a list of pages to generate. Instead of using Airtable,
// fetch it from a pages.json file.
// TODO we could fetch this from local if we run 'generate-marketing-data' first
let models = await axios.get('http://www.rosettastone.com/lp/static/data/us/pages.json')
console.log('----- last mdoel ----')
console.log(models.data.reverse()[0])
// ['sitewide', 'rmsitewide', 'sale', etc]
models = models.data.map(o => {
console.log('---- 0 ------')
//console.log(o)
//console.log('Name: ', o.name)
//return o.name
})
// ['sbsr/sitewide', 'sbsr/rmsitewide', 'nsrb/sitewide', ...]
models = _.flatMapDeep(templates.map(t => models.map(m => `${t}/${m}`)))
return models.map(async r => {
let products = await axios.get(`https://www.rosettastone.com/lp/static/data/us/products-json/sitewide.json`)
return {route: r, payload: products}
} )
}
},