Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@galactiks/explorer): bring support for scheduled contents #95

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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