Skip to content

Commit 0ec125b

Browse files
committed
chore: Remove newsletter links.
1 parent a155d84 commit 0ec125b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

_posts/nextjsemail.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ date: '2024-07-12T10:35:07.322Z'
1212

1313
My favorite spot to catch up with writers and artists is from the comfort of my own email inbox. Social media algorithms are fickle and too bite-sized to be sustaining. But sitting down for a couple of minutes to read an email long form is a delight!
1414

15-
I was curious about implementing the infrastructure for this very site. I don't plan on going full-on email marketer! I am interested, though, in a once or twice a year short note on what's going on in my corner of the internet.
15+
I was curious about implementing the infrastructure for this very site. I don't plan on going full-on email marketer! I am interested, though, in a once or twice a year short note on what's going on in my corner of the internet.
1616

1717
And, the fun part — It means getting to write some node code to set up an email subscription flow!
1818

@@ -42,13 +42,13 @@ export default function Subscribe() {
4242
const [firstName, setFirstName] = useState('');
4343
const [lastName, setLastName] = useState('');
4444
const [email, setEmail] = useState('');
45-
const [frequency, setFrequency] = useState('ALL');
45+
const [frequency, setFrequency] = useState('ALL');
4646
const [submitting, setSubmitting] = useState(false);
4747
const [error, setError] = useState(false);
4848
const router = useRouter();
49-
49+
5050
...
51-
51+
5252
}
5353
```
5454

@@ -74,7 +74,7 @@ return (
7474
<input type="text" id="lastName" name="lastName" required value={lastName} onChange={e => setLastName(e.currentTarget.value)} /><br />
7575
<label htmlFor="email">Email:</label><br />
7676
<input type="email" id="email" name="email" required value={email} onChange={e => setEmail(e.currentTarget.value)} /><br />
77-
77+
7878
<button type="submit" disabled={submitting}>{submitting ? 'Submitting...' : 'Sign Me Up!'}</button>
7979
{error && (
8080
<p>Oops! Something went wrong... try refreshing. If all else fails, <Link href={`/contact`}>
@@ -89,7 +89,6 @@ return (
8989
9090
Next I'll handle radio elements for emailing frequency. Most input fields are simple enough with one element. Radio elements, however, require special logic to work. Here, I'm setting the value to true only if our state matches the current element. The `onChange` is then responsible for updating the state to its value.
9191
92-
9392
```HTML
9493
<fieldset value={frequency}>
9594
<legend>How often would you like to receive emails?</legend>
@@ -105,10 +104,8 @@ Next I'll handle radio elements for emailing frequency. Most input fields are si
105104
106105
```
107106
108-
Now for submitting the form! My submit handler will set the submitting state so the input button won't accidentally be double-clicked.
107+
Now for submitting the form! My submit handler will set the submitting state so the input button won't accidentally be double-clicked.
109108

110-
Then, I'll gather the values from state. From there, the `fetch` API is used to send the request. And upon successful submission, the user is then redirected to `/subscribed?n={firstName}`. The query param is added to customize the message when they land.
109+
Then, I'll gather the values from state. From there, the `fetch` API is used to send the request. And upon successful submission, the user is then redirected to `/subscribed?n={firstName}`. The query param is added to customize the message when they land.
111110
112111
That's all there is to it! There's more work involved with handling updating subscription status and using the templates. If your curious, I'd recommend digging into Pete Houston's [Simple Newsletter repo](https://github.com/petehouston/simple-newsletter) and playing with it yourself!
113-
114-
Oh, _by the way!_ You can see the [working page here](/subscribe)!

0 commit comments

Comments
 (0)