From 6ad307b5ce6bbcaaec028182ee5aa565b805c287 Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Sun, 29 Oct 2023 15:47:07 +0100 Subject: [PATCH] feat(@galactiks/explorer): bring support for scheduled contents --- packages/explorer/src/core/content/compute.mts | 2 -- .../src/core/content/repositories/generated.mts | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/explorer/src/core/content/compute.mts b/packages/explorer/src/core/content/compute.mts index e6ebc183..95272745 100644 --- a/packages/explorer/src/core/content/compute.mts +++ b/packages/explorer/src/core/content/compute.mts @@ -109,8 +109,6 @@ const computeRemainingListingPages = async ( const translationOfWorkDocument = getDocumentByIdentifier( _d.translationOfWork['@id'] ); - console.log(_d.translationOfWork, translationOfWorkDocument); - if (translationOfWorkDocument?.isPartOf) { translationOfWork = { type: 'Id', diff --git a/packages/explorer/src/core/content/repositories/generated.mts b/packages/explorer/src/core/content/repositories/generated.mts index 264a624c..d21eb7d6 100644 --- a/packages/explorer/src/core/content/repositories/generated.mts +++ b/packages/explorer/src/core/content/repositories/generated.mts @@ -14,6 +14,8 @@ import type { RepositoryFilters, WebPageElementFilters } from './filters.mjs'; let _generated: ContentlayerDataExports; let _documents: Content[]; +const dateNow = new Date() + const documentsByLanguagesSelector = >(documents: T[]) => (inLanguages: string[]) => @@ -51,14 +53,16 @@ const getWebPageDocuments = async (): Promise => { const config = getConfig(); const generated = await getGenerated(); + const publishedDocuments = new Array() + .concat(generated.allPages || []) + .concat(generated.allArticles || []) + .concat(generated.allPeople || []) + .concat(generated.allPlaces || []) + .filter(_d => !_d.datePublished || new Date(_d.datePublished) <= dateNow); _documents = await computeDocuments({ config, websites: await getWebsites(), - documents: new Array() - .concat(generated.allPages || []) - .concat(generated.allArticles || []) - .concat(generated.allPeople || []) - .concat(generated.allPlaces || []), + documents: publishedDocuments, people: generated.allPeople || [], });