Generate sitemap-endpoints json

This commit is contained in:
Sam Carlton 2021-02-23 22:12:50 -06:00
parent e8b18eea13
commit 2b69a10c04

View file

@ -23,11 +23,13 @@ class BuildLists {
// Where our lists are stored // Where our lists are stored
this.lists = {} this.lists = {}
// Where Nuxt Routes and Payloads get stored this.endpointSets = {
this.nuxtEndpointsSet = new Set() // Where Nuxt Routes and Payloads get stored
nuxtEndpointsSet: new Set(),
// Where Eleventy Enpoints get stored // Where Eleventy Endpoints get stored
this.eleventyEndpointsSet = new Set() eleventyEndpointsSet: new Set()
}
this.allVideoAppsList = new Set() this.allVideoAppsList = new Set()
} }
@ -225,7 +227,7 @@ class BuildLists {
const isGame = (app.category === 'games') const isGame = (app.category === 'games')
if (isVideo) { if (isVideo) {
this.eleventyEndpointsSet.add({ this.endpointSets.eleventyEndpointsSet.add({
route: getVideoEndpoint(app), route: getVideoEndpoint(app),
// payload: buildVideoPayload( app, this.allVideoAppsList, this.lists.video ) // payload: buildVideoPayload( app, this.allVideoAppsList, this.lists.video )
}) })
@ -235,13 +237,13 @@ class BuildLists {
// Add benchmark endpoints for apps and games // Add benchmark endpoints for apps and games
if ( isApp || isGame ) { if ( isApp || isGame ) {
this.nuxtEndpointsSet.add({ this.endpointSets.nuxtEndpointsSet.add({
route: `${getAppEndpoint(app)}/benchmarks`, route: `${getAppEndpoint(app)}/benchmarks`,
payload: buildAppBenchmarkPayload( app, this.allVideoAppsList, this.lists.video ) payload: buildAppBenchmarkPayload( app, this.allVideoAppsList, this.lists.video )
}) })
} }
this.nuxtEndpointsSet.add({ this.endpointSets.nuxtEndpointsSet.add({
route: getAppEndpoint(app), route: getAppEndpoint(app),
payload: { app } payload: { app }
}) })
@ -253,7 +255,7 @@ class BuildLists {
Object.keys(categories).forEach( slug => { Object.keys(categories).forEach( slug => {
this.nuxtEndpointsSet.add({ this.endpointSets.nuxtEndpointsSet.add({
route: '/kind/' + slug, route: '/kind/' + slug,
// payload: appList // payload: appList
}) })
@ -261,10 +263,15 @@ class BuildLists {
// Save Nuxt Endpoints // Save Nuxt Endpoints
await this.saveToJson(Array.from(this.nuxtEndpointsSet), './static/nuxt-endpoints.json') await this.saveToJson(Array.from(this.endpointSets.nuxtEndpointsSet), './static/nuxt-endpoints.json')
// Save Eleventy Endpoints // Save Eleventy Endpoints
await this.saveToJson(Array.from(this.eleventyEndpointsSet), './static/eleventy-endpoints.json') await this.saveToJson(Array.from(this.endpointSets.eleventyEndpointsSet), './static/eleventy-endpoints.json')
// Save sitemap endpoints
await this.saveToJson(Object.values(this.endpointSets).map( endpointSet => {
return Array.from( endpointSet )
} ).flat(1), './static/sitemap-endpoints.json')
return return
} }