Skip to content

Commit

Permalink
✨ add getCover helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuxu committed Jun 6, 2023
1 parent 03498e2 commit 9311bf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/notion-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @vargtech/notion-utils

## 0.0.6

### Patch Changes

- add getCover

## 0.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/notion-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vargtech/notion-utils",
"version": "0.0.5",
"version": "0.0.6",
"description": "Helper functions for the Notion API",
"author": "Julian Jark",
"license": "ISC",
Expand Down
9 changes: 9 additions & 0 deletions packages/notion-utils/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ export const getDate = (name: string, fromPage: PageObjectResponse) => {
return undefined;
};

export const getCover = (fromPage: PageObjectResponse) => {
if (fromPage.cover?.type === "external") {
return fromPage.cover.external.url;
} else if (fromPage.cover?.type === "file") {
return fromPage.cover.file.url;
}
return undefined;
};

export const getImage = (name: string, fromPage: PageObjectResponse) => {
const property = fromPage.properties[name];
if (property?.type === "files") {
Expand Down

0 comments on commit 9311bf3

Please sign in to comment.