From 12a922b2ba166cdcd5d3b8b2eb050c578f85a8a0 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 23:10:24 -0600 Subject: [PATCH] Sort videos newest first --- helpers/build-video-list.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 4341851..cf1d199 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -2,7 +2,8 @@ import slugify from 'slugify' import axios from 'axios' - +import { byTimeThenNull } from './sort-list.js' +import parseGithubDate from './parse-github-date' const videoFeaturesApp = function (app, video) { const appFuzzyName = app.name.toLowerCase() @@ -42,9 +43,19 @@ export default async function ( applist ) { } } + // console.log('fetchedVideos[videoId].rawData.snippet.publishedAt', fetchedVideos[videoId].rawData.snippet.publishedAt) + + const lastUpdated = { + raw: fetchedVideos[videoId].rawData.snippet.publishedAt, + timestamp: parseGithubDate(fetchedVideos[videoId].rawData.snippet.publishedAt).timestamp, + } + + // console.log('lastUpdated', lastUpdated) + videos.push({ name: fetchedVideos[videoId].title, id: videoId, + lastUpdated, apps, slug, timestamps: fetchedVideos[videoId].timestamps, @@ -54,5 +65,7 @@ export default async function ( applist ) { // console.log('videos', videos) - return videos + // publishedAt + + return videos.sort(byTimeThenNull) }