Skip to content
Open
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
25 changes: 20 additions & 5 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
/* Step 1: enter your domain name like fruitionsite.com */
const MY_DOMAIN = "fruitionsite.com";

/* Step 2: enter workspace 'domain' value on notion.so
* > settings & members > settings > domain
*/
const SPACE_DOMAIN = 'stephenou';

/*
* Step 2: enter your URL slug to page ID mapping
* Step 3: enter your URL slug to page ID mapping
* The key on the left is the slug (without the slash)
* The value on the right is the Notion page ID
*/
Expand All @@ -15,15 +20,15 @@ const SLUG_TO_PAGE = {
roadmap: "7d4b21bfb4534364972e8bf9f68c2c36"
};

/* Step 3: enter your page title and description for SEO purposes */
/* Step 4: enter your page title and description for SEO purposes */
const PAGE_TITLE = "Fruition";
const PAGE_DESCRIPTION =
"Free, Open Source Toolkit For Customizing Your Notion Page";

/* Step 4: enter a Google Font name, you can choose from https://fonts.google.com */
/* Step 5: enter a Google Font name, you can choose from https://fonts.google.com */
const GOOGLE_FONT = "Rubik";

/* Step 5: enter any custom scripts you'd like */
/* Step 6: enter any custom scripts you'd like */
const CUSTOM_SCRIPT = ``;

/* CONFIGURATION ENDS HERE */
Expand Down Expand Up @@ -115,7 +120,17 @@ async function fetchAndApply(request) {
},
method: "POST"
});
response = new Response(response.body, response);

let body = await response.text()
const data = JSON.parse(body);

if (url.pathname.includes("getPublicPageData")) {
if(data.spaceDomain!=SPACE_DOMAIN){
throw new Error('Not found on this notion account!')
}
}

response = new Response(body, response);
response.headers.set("Access-Control-Allow-Origin", "*");
} else if (slugs.indexOf(url.pathname.slice(1)) > -1) {
const pageId = SLUG_TO_PAGE[url.pathname.slice(1)];
Expand Down