-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4913cb
commit 703c9fe
Showing
28 changed files
with
155 additions
and
217 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
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,47 +1,51 @@ | ||
// Import necessary libraries and components | ||
import notion from "@/lib"; | ||
import { Article } from "@/layouts/types"; | ||
import { convertToPost } from "./convertToPost"; | ||
// // Import necessary libraries and components | ||
// import notion from "@/lib"; | ||
// import { Article } from "@/lib/types"; | ||
// import { convertToPost } from "./convertToPost"; | ||
|
||
export const getPublishedPostsByTag = async (tags?: string[]): Promise<Article[]> => { | ||
const databaseId = process.env.NOTION_DATABASE_ID!; | ||
// export const getPublishedPostsByTag = async (tags?: string[]): Promise<Article[]> => { | ||
// const databaseId = process.env.NOTION_DATABASE_ID!; | ||
|
||
// Create filter based on whether tags are provided | ||
const filter = tags | ||
? [ | ||
{ | ||
property: "status", | ||
select: { | ||
equals: "Published", | ||
}, | ||
}, | ||
{ | ||
property: "tags", // Assuming tags is the property name in your database | ||
multi_select: { | ||
contains_all: tags, | ||
}, | ||
}, | ||
] | ||
: { | ||
property: "status", | ||
select: { | ||
equals: "Published", | ||
}, | ||
}; | ||
// // Create filter based on whether tags are provided | ||
// const filter = { | ||
// and: [ | ||
// { | ||
// property: "status", | ||
// select: { | ||
// equals: "Published", | ||
// }, | ||
// }, | ||
// { | ||
// property: "type", | ||
// select: { | ||
// equals: "Post", | ||
// }, | ||
// }, | ||
// { | ||
// property: "tags", // Assuming "tags" is the property name in your database | ||
// multi_select: { | ||
// contains_all: tags, | ||
// }, | ||
// }, | ||
// ] | ||
// }; | ||
|
||
const response = await notion.databases.query({ | ||
database_id: databaseId, | ||
sorts: [ | ||
{ | ||
property: "date", | ||
direction: "ascending", | ||
}, | ||
], | ||
}); | ||
// const response = await notion.databases.query({ | ||
// database_id: databaseId, | ||
// filter: { | ||
// or: [filter], // Wrap filter inside an array if needed | ||
// }, | ||
// sorts: [ | ||
// { | ||
// property: "date", | ||
// direction: "ascending", | ||
// }, | ||
// ], | ||
// }); | ||
|
||
const getPublishedPostsByTag: Article[] = response.results.map((e) => | ||
convertToPost(e) | ||
); | ||
// const getPublishedPostsByTag: Article[] = response.results.map((e) => | ||
// convertToPost(e) | ||
// ); | ||
|
||
return getPublishedPostsByTag; | ||
}; | ||
// return getPublishedPostsByTag; | ||
// }; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.