Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

feat: add catapult mailer support #54

Merged
merged 24 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineConfig } from "astro/config";

import netlify from "@astrojs/netlify/functions";

// https://astro.build/config
export default defineConfig({
redirects: {
"/branding": "/brand",
},
output: "server",
adapter: netlify(),
});
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
status = 200
51 changes: 0 additions & 51 deletions netlify/functions/fetch/fetch.js

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "1.1.0",
"private": true,
"dependencies": {
"@astrojs/netlify": "^5.2.1",
"astro": "^4.0.4",
"axios": "^1.6.2",
"magick.css": "^1.0.5",
"normalize.css": "^8.0.1",
"axios": "^1.6.2",
"qs": "^6.12.0"
},
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const year = new Date().getFullYear();
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<meta property="twitter:card" content="summary_large_image" />
<script defer src="https://umami.purplebubble.org/script.js" data-website-id="3d88503b-9747-416a-a176-7507ffb7c090"></script>
<script
defer
src="https://umami.purplebubble.org/script.js"
data-website-id="3d88503b-9747-416a-a176-7507ffb7c090"></script>
<link
rel="apple-touch-icon"
sizes="180x180"
Expand Down
39 changes: 34 additions & 5 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
---
import Layout from "../layouts/Layout.astro";

let error;
if (Astro.request.method === "POST") {
try {
const data = await Astro.request.formData();
const name = data.get("name");
const email = data.get("email");

const response = await fetch(
"https://catapult.purplebubble.org/api/subscribe",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ name, email }),
},
);

const jsondata = await response.json();
console.log(jsondata);
if ((jsondata.ok = true)) {
//do nothing
} else {
error = jsondata.error;
}
} catch (anError) {
if (anError instanceof Error) {
console.log(anError);
}
}
}
---

<Layout title="Purple Bubble" fiscalSponsor="true">
Expand All @@ -24,11 +56,8 @@ import Layout from "../layouts/Layout.astro";
</p>
</section>
<section>
<form
action="https://postal.hackclub.com/subscribe"
method="POST"
accept-charset="utf-8"
>
{error && <p class="text-red-500">Error: {error}</p>}
<form method="POST" accept-charset="utf-8">
<label for="name">Name</label><br />
<input
type="text"
Expand Down
Loading