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

Commit

Permalink
feat: add catapult mailer support (#54)
Browse files Browse the repository at this point in the history
* Update fetch.js this might not work.....

Signed-off-by: Emperor Numerius <[email protected]>

* Delete netlify/functions/fetch directory

deleted

Signed-off-by: Emperor Numerius <[email protected]>

* Update index.astro

add the fetch functionality i think

Signed-off-by: Emperor Numerius <[email protected]>

* Delete netlify.toml

Signed-off-by: Emperor Numerius <[email protected]>

* Create netlify.toml

Signed-off-by: Emperor Numerius <[email protected]>

* d

* j

* should work now

* now it should work

* i forgot about the semicolon

* bugs

* h

* f

* text

* gh

* ,

* n

* fgds

* Delete .vscode/settings.json

Signed-off-by: Kieran Klukas <[email protected]>

* bug: fix js

Signed-off-by: Kieran Klukas <[email protected]>

* Update index.astro

Signed-off-by: Kieran Klukas <[email protected]>

* fix: handle error response in index.astro

* chore: Update Astro config for server output and Netlify adapter

* chore: run prettier

---------

Signed-off-by: Emperor Numerius <[email protected]>
Signed-off-by: Kieran Klukas <[email protected]>
Co-authored-by: Kieran Klukas <[email protected]>
  • Loading branch information
EmperorNumerius and taciturnaxolotl authored Jun 1, 2024
1 parent ffdfd7e commit 9f169c3
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 59 deletions.
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

0 comments on commit 9f169c3

Please sign in to comment.