mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Filter eleventy endpoints by route, not payload
This commit is contained in:
parent
44fa023a06
commit
37a296adfe
4 changed files with 16 additions and 16 deletions
|
|
@ -56,4 +56,10 @@ export function getVideoEndpoint ( video ) {
|
||||||
return `/tv/${video.slug}`
|
return `/tv/${video.slug}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRouteType ( routeString ) {
|
||||||
|
// Remove first slash and split by remaining
|
||||||
|
// slashes to get first part of route
|
||||||
|
const [ routeType ] = routeString.substring(1).split('/')
|
||||||
|
|
||||||
|
return routeType
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import dotenv from 'dotenv'
|
||||||
|
|
||||||
import config from '../nuxt.config.js'
|
import config from '../nuxt.config.js'
|
||||||
|
|
||||||
import { getAppType } from '../helpers/app-derived.js'
|
import { getAppType, getRouteType } from '../helpers/app-derived.js'
|
||||||
import { deviceSupportsApp } from '../helpers/devices.js'
|
import { deviceSupportsApp } from '../helpers/devices.js'
|
||||||
import { makeLastUpdatedFriendly } from '../helpers/parse-date'
|
import { makeLastUpdatedFriendly } from '../helpers/parse-date'
|
||||||
|
|
||||||
|
|
@ -56,12 +56,10 @@ export class AppTemplate {
|
||||||
|
|
||||||
before: function( data ) {
|
before: function( data ) {
|
||||||
return data.filter( entry => {
|
return data.filter( entry => {
|
||||||
// Skip endpoints with no payload
|
// const [ _, routeType ] = entry.route.split('/')
|
||||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
const routeType = getRouteType( entry.route )
|
||||||
|
|
||||||
const appType = getAppType( entry.payload.app )
|
return routeType === 'app'
|
||||||
|
|
||||||
return appType === 'app'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import dotenv from 'dotenv'
|
||||||
|
|
||||||
import config from '../nuxt.config.js'
|
import config from '../nuxt.config.js'
|
||||||
|
|
||||||
import { getAppType } from '../helpers/app-derived.js'
|
import { getAppType, getRouteType } from '../helpers/app-derived.js'
|
||||||
|
|
||||||
import { AppTemplate } from './app.11ty.js'
|
import { AppTemplate } from './app.11ty.js'
|
||||||
|
|
||||||
|
|
@ -33,12 +33,9 @@ class FormulaTemplate extends AppTemplate {
|
||||||
alias: 'app',
|
alias: 'app',
|
||||||
before: function( data ) {
|
before: function( data ) {
|
||||||
return data.filter( entry => {
|
return data.filter( entry => {
|
||||||
// Skip endpoints with no payload
|
const routeType = getRouteType( entry.route )
|
||||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
|
||||||
|
|
||||||
const appType = getAppType( entry.payload.app )
|
return routeType === 'formula'
|
||||||
|
|
||||||
return appType === 'formula'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import dotenv from 'dotenv'
|
||||||
import config from '../nuxt.config'
|
import config from '../nuxt.config'
|
||||||
|
|
||||||
import VideoRow from '../components-eleventy/video/row.js'
|
import VideoRow from '../components-eleventy/video/row.js'
|
||||||
import { isVideo } from '../helpers/app-derived'
|
import { isVideo, getRouteType } from '../helpers/app-derived'
|
||||||
|
|
||||||
// Setup dotenv
|
// Setup dotenv
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
@ -35,10 +35,9 @@ class TV {
|
||||||
alias: 'payload',
|
alias: 'payload',
|
||||||
before: function( data ) {
|
before: function( data ) {
|
||||||
return data.filter( entry => {
|
return data.filter( entry => {
|
||||||
// Skip endpoints with no payload
|
const routeType = getRouteType( entry.route )
|
||||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
|
||||||
|
|
||||||
return entry.payload.hasOwnProperty('video') && isVideo( entry.payload.video )
|
return routeType === 'tv'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue