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}`
|
||||
}
|
||||
|
||||
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 { getAppType } from '../helpers/app-derived.js'
|
||||
import { getAppType, getRouteType } from '../helpers/app-derived.js'
|
||||
import { deviceSupportsApp } from '../helpers/devices.js'
|
||||
import { makeLastUpdatedFriendly } from '../helpers/parse-date'
|
||||
|
||||
|
|
@ -56,12 +56,10 @@ export class AppTemplate {
|
|||
|
||||
before: function( data ) {
|
||||
return data.filter( entry => {
|
||||
// Skip endpoints with no payload
|
||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
||||
// const [ _, routeType ] = entry.route.split('/')
|
||||
const routeType = getRouteType( entry.route )
|
||||
|
||||
const appType = getAppType( entry.payload.app )
|
||||
|
||||
return appType === 'app'
|
||||
return routeType === 'app'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import dotenv from 'dotenv'
|
|||
|
||||
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'
|
||||
|
||||
|
|
@ -33,12 +33,9 @@ class FormulaTemplate extends AppTemplate {
|
|||
alias: 'app',
|
||||
before: function( data ) {
|
||||
return data.filter( entry => {
|
||||
// Skip endpoints with no payload
|
||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
||||
const routeType = getRouteType( entry.route )
|
||||
|
||||
const appType = getAppType( entry.payload.app )
|
||||
|
||||
return appType === 'formula'
|
||||
return routeType === 'formula'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import dotenv from 'dotenv'
|
|||
import config from '../nuxt.config'
|
||||
|
||||
import VideoRow from '../components-eleventy/video/row.js'
|
||||
import { isVideo } from '../helpers/app-derived'
|
||||
import { isVideo, getRouteType } from '../helpers/app-derived'
|
||||
|
||||
// Setup dotenv
|
||||
dotenv.config()
|
||||
|
|
@ -35,10 +35,9 @@ class TV {
|
|||
alias: 'payload',
|
||||
before: function( data ) {
|
||||
return data.filter( entry => {
|
||||
// Skip endpoints with no payload
|
||||
if ( entry === undefined || !entry.hasOwnProperty('payload') ) return false
|
||||
const routeType = getRouteType( entry.route )
|
||||
|
||||
return entry.payload.hasOwnProperty('video') && isVideo( entry.payload.video )
|
||||
return routeType === 'tv'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue