diff --git a/resources/views/components/newsletter-modal.blade.php b/resources/views/components/newsletter-modal.blade.php
index f1b127ed..74001d08 100644
--- a/resources/views/components/newsletter-modal.blade.php
+++ b/resources/views/components/newsletter-modal.blade.php
@@ -1,15 +1,23 @@
{{--
Newsletter signup modal. Opened from anywhere on the site by dispatching an
`open-newsletter-modal` window event, so triggers don't have to be nested
- inside it. The form posts straight to Mailcoach, which then redirects to one
- of our own `newsletter.*` pages depending on the outcome.
+ inside it. It also opens itself when the page is loaded with `?newsletter` in
+ the URL, which is where the `/newsletter` shortlink sends people. The form
+ posts straight to Mailcoach, which then redirects to one of our own
+ `newsletter.*` pages depending on the outcome.
--}}
$refs.email?.focus())
- "
+ x-data="{
+ open: false,
+ show() {
+ this.open = true
+ this.$nextTick(() => this.$refs.email?.focus())
+ },
+ }"
+ @if (request()->has('newsletter'))
+ x-init="show()"
+ @endif
+ @open-newsletter-modal.window="show()"
@keydown.escape.window="open = false"
>
{{-- Backdrop --}}
diff --git a/routes/web.php b/routes/web.php
index 330fecce..8d281a6e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -62,7 +62,8 @@
|
*/
-Route::redirect('newsletter', 'https://simonhamp.mailcoach.app/nativephp');
+// The shortlink lands on the homepage and pops the signup modal open.
+Route::redirect('newsletter', '/?newsletter=1');
Route::redirect('phpverse-2025', 'https://lp.jetbrains.com/phpverse-2025');
Route::redirect('docs/1/getting-started/sponsoring', '/sponsor');
Route::redirect('docs/desktop/1/getting-started/sponsoring', '/sponsor');
diff --git a/tests/Feature/NewsletterSignupTest.php b/tests/Feature/NewsletterSignupTest.php
index ec90836d..7a990bd4 100644
--- a/tests/Feature/NewsletterSignupTest.php
+++ b/tests/Feature/NewsletterSignupTest.php
@@ -73,6 +73,29 @@ public function the_modal_is_available_on_every_page_of_the_site()
->assertSee(config('services.mailcoach.newsletter_subscribe_url'), escape: false);
}
+ #[Test]
+ public function the_newsletter_shortlink_sends_people_to_the_homepage_with_the_modal_open()
+ {
+ $this->get('/newsletter')
+ ->assertRedirect('/?newsletter=1');
+ }
+
+ #[Test]
+ public function the_modal_opens_itself_when_the_url_asks_for_it()
+ {
+ $this->get('/?newsletter=1')
+ ->assertOk()
+ ->assertSee('x-init="show()"', escape: false);
+ }
+
+ #[Test]
+ public function the_modal_stays_closed_on_a_normal_page_load()
+ {
+ $this->get('/')
+ ->assertOk()
+ ->assertDontSee('x-init="show()"', escape: false);
+ }
+
#[Test]
public function the_confirmation_page_tells_people_to_check_their_inbox()
{