diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2ccbe46
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/node_modules/
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..b21b7fe
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "api-worker",
+ "version": "0.0.1+alpha-build01",
+ "private": true,
+ "scripts": {
+ "deploy": "wrangler deploy",
+ "start": "wrangler dev"
+ },
+ "devDependencies": {
+ "wrangler": "^3.28.0"
+ }
+}
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
new file mode 100644
index 0000000..66bb30e
--- /dev/null
+++ b/src/index.js
@@ -0,0 +1,61 @@
+addEventListener('fetch', event => {
+ event.respondWith(handleRequest(event.request));
+ });
+
+ async function handleRequest(request) {
+ const url = new URL(request.url);
+
+ // Check if the path is /blog
+ if (url.pathname === '/blog') {
+ // Fetch the index.json file from your CDN
+ const response = await fetch('https://cdn.jonasjones.dev/blog/index.json');
+ const data = await response.json();
+
+ // Process the JSON data to create the RSS feed
+ const rssFeed = createRSSFeed(data);
+
+ // Return the RSS feed as the response
+ return new Response(rssFeed, {
+ headers: { 'Content-Type': 'application/rss+xml' },
+ });
+ } else {
+ // Handle other routes or return a 404 response
+ return new Response('Not Found', { status: 404 });
+ }
+ }
+
+ function createRSSFeed(data) {
+ const DOMAIN = 'https://blog.jonasjones.dev';
+ const items = data.slice(-50).reverse().map(item => `
+ -
+
+ ${DOMAIN}/#/post/${formatDateForLink(item.date)}/${item.id}
+ ${DOMAIN}/#/post/${formatDateForLink(item.date)}/${item.id}
+
+ ${new Date(item.date).toUTCString()}
+
+
+ `).join('');
+
+ return `
+
+
+ Your Blog Title
+ ${DOMAIN}
+ Your blog description
+ en-us
+ ${new Date().toUTCString()}
+ ${new Date().toUTCString()}
+ Cloudflare Worker
+ ${items}
+
+ `;
+ }
+
+ function formatDateForLink(dateString) {
+ const date = new Date(dateString);
+ const year = date.getUTCFullYear();
+ const month = String(date.getUTCMonth() + 1).padStart(2, '0');
+ const day = String(date.getUTCDate()).padStart(2, '0');
+ return `${year}/${month}/${day}`;
+ }
diff --git a/wrangler.toml b/wrangler.toml
new file mode 100644
index 0000000..f5777f4
--- /dev/null
+++ b/wrangler.toml
@@ -0,0 +1,51 @@
+name = "rss-worker"
+main = "src/index.js"
+compatibility_date = "2023-09-04"
+
+# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
+# Note: Use secrets to store sensitive data.
+# Docs: https://developers.cloudflare.com/workers/platform/environment-variables
+# [vars]
+# MY_VARIABLE = "production_value"
+
+# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
+# Docs: https://developers.cloudflare.com/workers/runtime-apis/kv
+# [[kv_namespaces]]
+# binding = "MY_KV_NAMESPACE"
+# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+
+# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
+# Docs: https://developers.cloudflare.com/r2/api/workers/workers-api-usage/
+# [[r2_buckets]]
+# binding = "MY_BUCKET"
+# bucket_name = "my-bucket"
+
+# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
+# Docs: https://developers.cloudflare.com/queues/get-started
+# [[queues.producers]]
+# binding = "MY_QUEUE"
+# queue = "my-queue"
+
+# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
+# Docs: https://developers.cloudflare.com/queues/get-started
+# [[queues.consumers]]
+# queue = "my-queue"
+
+# Bind another Worker service. Use this binding to call another Worker without network overhead.
+# Docs: https://developers.cloudflare.com/workers/platform/services
+# [[services]]
+# binding = "MY_SERVICE"
+# service = "/api/*"
+
+# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
+# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
+# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
+# [[durable_objects.bindings]]
+# name = "MY_DURABLE_OBJECT"
+# class_name = "MyDurableObject"
+
+# Durable Object migrations.
+# Docs: https://developers.cloudflare.com/workers/learning/using-durable-objects#configure-durable-object-classes-with-migrations
+# [[migrations]]
+# tag = "v1"
+# new_classes = ["MyDurableObject"]
\ No newline at end of file