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
10 changes: 6 additions & 4 deletions worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* CONFIGURATION STARTS HERE */

/* Step 1: enter your domain name like fruitionsite.com */
/* Step 1: enter your domain name like www.(fruitionsite.com) and (fruition).notion.site */
const MY_DOMAIN = "fruitionsite.com";
const MY_NOTION_DOMAIN = "fruition";

/*
* Step 2: enter your URL slug to page ID mapping
Expand Down Expand Up @@ -84,7 +85,7 @@ async function fetchAndApply(request) {
return handleOptions(request);
}
let url = new URL(request.url);
url.hostname = 'www.notion.so';
url.hostname = MY_NOTION_DOMAIN + '.notion.site';
if (url.pathname === "/robots.txt") {
return new Response("Sitemap: https://" + MY_DOMAIN + "/sitemap.xml");
}
Expand All @@ -100,7 +101,8 @@ async function fetchAndApply(request) {
response = new Response(
body
.replace(/www.notion.so/g, MY_DOMAIN)
.replace(/notion.so/g, MY_DOMAIN),
.replace(/notion.so/g, MY_DOMAIN)
.replace(/${MY_NOTION_DOMAIN}.notion.site/g, MY_DOMAIN),
response
);
response.headers.set("Content-Type", "application/x-javascript");
Expand Down Expand Up @@ -315,7 +317,7 @@ class BodyRewriter {
};
const open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function() {
arguments[1] = arguments[1].replace('${MY_DOMAIN}', 'www.notion.so');
arguments[1] = arguments[1].replace('${MY_DOMAIN}', '${MY_NOTION_DOMAIN}.notion.site');
return open.apply(this, [].slice.call(arguments));
};
</script>${CUSTOM_SCRIPT}`,
Expand Down