mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Generate sitemap endpoints from json
This commit is contained in:
parent
17b3527778
commit
f36f25cfa7
2 changed files with 32 additions and 11 deletions
|
|
@ -25,10 +25,10 @@ class BuildLists {
|
||||||
|
|
||||||
this.endpointSets = {
|
this.endpointSets = {
|
||||||
// Where Nuxt Routes and Payloads get stored
|
// Where Nuxt Routes and Payloads get stored
|
||||||
nuxtEndpointsSet: new Set(),
|
nuxt: new Set(),
|
||||||
|
|
||||||
// Where Eleventy Endpoints get stored
|
// Where Eleventy Endpoints get stored
|
||||||
eleventyEndpointsSet: new Set()
|
eleventy: new Set()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.allVideoAppsList = new Set()
|
this.allVideoAppsList = new Set()
|
||||||
|
|
@ -227,9 +227,14 @@ class BuildLists {
|
||||||
const isGame = (app.category === 'games')
|
const isGame = (app.category === 'games')
|
||||||
|
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
this.endpointSets.eleventyEndpointsSet.add({
|
// this.endpointSets.eleventy.add({
|
||||||
|
// route: getVideoEndpoint(app),
|
||||||
|
// // payload: buildVideoPayload( app, this.allVideoAppsList, this.lists.video )
|
||||||
|
// })
|
||||||
|
|
||||||
|
this.endpointSets.nuxt.add({
|
||||||
route: getVideoEndpoint(app),
|
route: getVideoEndpoint(app),
|
||||||
// payload: buildVideoPayload( app, this.allVideoAppsList, this.lists.video )
|
payload: buildVideoPayload( app, this.allVideoAppsList, this.lists.video )
|
||||||
})
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -237,13 +242,13 @@ class BuildLists {
|
||||||
|
|
||||||
// Add benchmark endpoints for apps and games
|
// Add benchmark endpoints for apps and games
|
||||||
if ( isApp || isGame ) {
|
if ( isApp || isGame ) {
|
||||||
this.endpointSets.nuxtEndpointsSet.add({
|
this.endpointSets.nuxt.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.endpointSets.nuxtEndpointsSet.add({
|
this.endpointSets.nuxt.add({
|
||||||
route: getAppEndpoint(app),
|
route: getAppEndpoint(app),
|
||||||
payload: { app }
|
payload: { app }
|
||||||
})
|
})
|
||||||
|
|
@ -255,7 +260,7 @@ class BuildLists {
|
||||||
|
|
||||||
|
|
||||||
Object.keys(categories).forEach( slug => {
|
Object.keys(categories).forEach( slug => {
|
||||||
this.endpointSets.nuxtEndpointsSet.add({
|
this.endpointSets.nuxt.add({
|
||||||
route: '/kind/' + slug,
|
route: '/kind/' + slug,
|
||||||
// payload: appList
|
// payload: appList
|
||||||
})
|
})
|
||||||
|
|
@ -263,10 +268,15 @@ class BuildLists {
|
||||||
|
|
||||||
|
|
||||||
// Save Nuxt Endpoints
|
// Save Nuxt Endpoints
|
||||||
await this.saveToJson(Array.from(this.endpointSets.nuxtEndpointsSet), './static/nuxt-endpoints.json')
|
// await this.saveToJson(Array.from(this.endpointSets.nuxt), './static/nuxt-endpoints.json')
|
||||||
|
|
||||||
// Save Eleventy Endpoints
|
// // Save Eleventy Endpoints
|
||||||
await this.saveToJson(Array.from(this.endpointSets.eleventyEndpointsSet), './static/eleventy-endpoints.json')
|
// await this.saveToJson(Array.from(this.endpointSets.eleventy), './static/eleventy-endpoints.json')
|
||||||
|
|
||||||
|
for ( const [ endpointSetName, endpointSet ] of Object.entries(this.endpointSets) ) {
|
||||||
|
// Save Endpoints
|
||||||
|
await this.saveToJson(Array.from( endpointSet ), `./static/${endpointSetName}-endpoints.json`)
|
||||||
|
}
|
||||||
|
|
||||||
// Save sitemap endpoints
|
// Save sitemap endpoints
|
||||||
await this.saveToJson(Object.values(this.endpointSets).map( endpointSet => {
|
await this.saveToJson(Object.values(this.endpointSets).map( endpointSet => {
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,18 @@ export default {
|
||||||
],
|
],
|
||||||
|
|
||||||
sitemap: {
|
sitemap: {
|
||||||
hostname: 'https://doesitarm.com'
|
hostname: 'https://doesitarm.com',
|
||||||
|
routes: async () => {
|
||||||
|
// Get routes from previous build
|
||||||
|
const sitemapEndpoints = await fs.readFile('./static/sitemap-endpoints.json', 'utf-8')
|
||||||
|
.then( endpointsJson => {
|
||||||
|
return JSON.parse(endpointsJson)
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('Total Sitemap Endpoints', sitemapEndpoints.length)
|
||||||
|
|
||||||
|
return sitemapEndpoints.map( endpoint => endpoint.route )
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
buildModules: [
|
buildModules: [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue