Skip to content

Commit

Permalink
Merge pull request #1 from shawakash/notion
Browse files Browse the repository at this point in the history
Notion
  • Loading branch information
shawakash authored Nov 27, 2023
2 parents 439bfab + 76c0e3d commit aab5763
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
16 changes: 10 additions & 6 deletions packages/backend/notion/src/lib/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ export const getDatabaseId = (databaseUrl: string) => {

export const getPageId = (url: string): string => {
// Use regular expressions to extract the ID from the URL
const match = url.match(/https:\/\/www\.notion\.so\/([a-zA-Z0-9-]+)\?/);

// If a match is found, return the captured ID group (first capturing group)
const regex = /https:\/\/www\.notion\.so\/([^?]+)/;
const match = url.match(regex);

if (match && match[1]) {
return match[1];
const idRegex = /[^/]+$/;
const idMatch = match[1].match(idRegex);

if (idMatch && idMatch[0]) {
return idMatch[0].split('-')[idMatch[0].split('-').length - 1];
}
}

// Return null if no match is found
return '';
}
}



Expand Down
10 changes: 2 additions & 8 deletions packages/backend/notion/src/routes/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ router.post('/createDb', async (req, res) => {

const notion = new Client({ auth: api_key });
let page_id = getPageId(page_url);
console.log(page_id, 'fro here')
if(getPageId(page_url) == '') {
page_id = uuid;
}

const response = await notion.databases.create({
parent: {
type: "page_id",
page_id: page_id,
page_id,
},
icon: {
type: "emoji",
Expand Down Expand Up @@ -101,13 +102,6 @@ router.post('/createDb', async (req, res) => {
"Last ordered": {
date: {},
},
"Number of meals": {
rollup: {
rollup_property_name: "Name",
relation_property_name: "Meals",
function: "count",
},
},
"Store availability": {
type: "multi_select",
multi_select: {
Expand Down

0 comments on commit aab5763

Please sign in to comment.