Pull title and description from tvEntry

This commit is contained in:
Sam Carlton 2021-05-13 22:23:14 -05:00
parent 3b36f4f26c
commit b2c9774ca8

View file

@ -3,13 +3,15 @@ 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, getRouteType } from '../helpers/app-derived' import { getRouteType } from '../helpers/app-derived'
// Setup dotenv // Setup dotenv
dotenv.config() dotenv.config()
export const makeTitle = function ( tvEntry ) { export const makeTitle = function ( name ) {
return `${ tvEntry.name } - ${ config.head.title }` // console.log('tvEntry', tvEntry)
return `${ name } - ${ config.head.title }`
} }
export const makeDescription = function ( tvEntry ) { export const makeDescription = function ( tvEntry ) {
@ -31,32 +33,42 @@ class TV {
pagination: { pagination: {
data: 'eleventy-endpoints', data: 'eleventy-endpoints',
// data: 'collections.tv',
size: 1, size: 1,
alias: 'tvEntry', alias: 'tvEntry',
before: function( data ) { before: function( endpoint ) {
return data.filter( entry => { // console.log('Before runs')
return endpoint.filter( entry => {
const routeType = getRouteType( entry.route ) const routeType = getRouteType( entry.route )
return routeType === 'tv' return routeType === 'tv'
}) })
} },
}, },
// tags: [ 'tv' ],
eleventyComputed: { eleventyComputed: {
title: ( { tvEntry } ) => { title: data => {
// console.log('data', data) // Declare dependencies for Eleventy
return makeTitle( tvEntry ) // https://www.11ty.dev/docs/data-computed/#declaring-your-dependencies
data.tvEntry
return makeTitle( data.tvEntry.payload.video.name )
}, },
description: ( { tvEntry } ) => { description: ( data ) => {
return makeDescription( tvEntry ) // Declare dependencies for Eleventy
// https://www.11ty.dev/docs/data-computed/#declaring-your-dependencies
data.tvEntry
return makeDescription( data.tvEntry )
}, },
}, },
permalink: ( { tvEntry: { route } } ) => { permalink: ( data ) => {
// console.log('data', data)
// return `tv/${ video.slug }/`
return route.substring(1) + '/' return data.tvEntry.route.substring(1) + '/'
} }
} }
} }
@ -71,13 +83,10 @@ class TV {
relatedVideos = [] relatedVideos = []
} }
}, },
// tvEntry: {
// video,
// relatedVideos = []
// },
// 'device-list': deviceList // 'device-list': deviceList
} = data } = data
// console.log('video.payload', Object.keys(video.payload)) // console.log('video.payload', Object.keys(video.payload))
const rowHtml = await this.boundComponent(VideoRow)( relatedVideos ) const rowHtml = await this.boundComponent(VideoRow)( relatedVideos )