Skip to content

Commit

Permalink
Merge pull request #95 from thegalactiks/scheduled-content
Browse files Browse the repository at this point in the history
feat(@galactiks/explorer): bring support for scheduled contents
  • Loading branch information
emmanuelgautier authored Oct 29, 2023
2 parents 427d525 + 6ad307b commit f631d95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions packages/explorer/src/core/content/compute.mts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ const computeRemainingListingPages = async (
const translationOfWorkDocument = getDocumentByIdentifier(
_d.translationOfWork['@id']
);
console.log(_d.translationOfWork, translationOfWorkDocument);

if (translationOfWorkDocument?.isPartOf) {
translationOfWork = {
type: 'Id',
Expand Down
14 changes: 9 additions & 5 deletions packages/explorer/src/core/content/repositories/generated.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { RepositoryFilters, WebPageElementFilters } from './filters.mjs';
let _generated: ContentlayerDataExports;
let _documents: Content[];

const dateNow = new Date()

const documentsByLanguagesSelector =
<T extends Pick<ContentlayerWebPageDocument, 'inLanguage'>>(documents: T[]) =>
(inLanguages: string[]) =>
Expand Down Expand Up @@ -51,14 +53,16 @@ const getWebPageDocuments = async (): Promise<Content[]> => {
const config = getConfig();

const generated = await getGenerated();
const publishedDocuments = new Array<ContentlayerWebPageDocument>()
.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<ContentlayerWebPageDocument>()
.concat(generated.allPages || [])
.concat(generated.allArticles || [])
.concat(generated.allPeople || [])
.concat(generated.allPlaces || []),
documents: publishedDocuments,
people: generated.allPeople || [],
});

Expand Down

0 comments on commit f631d95

Please sign in to comment.