-
-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hide posts in Prod with future pubDatetime (#234)
* Hide posts when PubDateTime is not reached * refactor: extract filter logic into a file * docs: update SITE config docs --------- Co-authored-by: satnaing <satnaingdev@gmail.com>
- Loading branch information
Showing
7 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SITE } from "@config"; | ||
import type { CollectionEntry } from "astro:content"; | ||
|
||
const postFilter = ({ data }: CollectionEntry<"blog">) => { | ||
const isPublishTimePassed = | ||
Date.now() > | ||
new Date(data.pubDatetime).getTime() - SITE.scheduledPostMargin; | ||
return !data.draft && (import.meta.env.DEV || isPublishTimePassed); | ||
}; | ||
|
||
export default postFilter; |