Skip to content

Commit

Permalink
Use the same partial for the lead magnet and the subscribe form
Browse files Browse the repository at this point in the history
  • Loading branch information
yanirs committed May 22, 2024
1 parent bc989b5 commit ee4cddc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 76 deletions.
2 changes: 1 addition & 1 deletion layouts/partials/comments.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- partial "subscribe_hover.html" . }}
{{- partial "subscribe_form.html" . }}
{{- partial "subscribe_form.html" (dict "context" .) }}

<section class="comment-section">
{{ $comments := index $.Site.Data.comments .File.ContentBaseName | default slice }}
Expand Down
31 changes: 25 additions & 6 deletions layouts/partials/subscribe_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"settings" (dict
"after_subscribe" (dict
"action" "message"
"success_message" "Success! Now check your email to confirm your subscription."
"success_message" (.success_message | default "Success! Now check your email to confirm your subscription.")
"redirect_url" ""
)
"recaptcha" (dict
Expand All @@ -20,23 +20,24 @@
"version" "5"
) | jsonify
}}
{{$formId := .form_id | default 6549537 }}

<div class="mailing-list-container">
<script src="https://f.convertkit.com/ckjs/ck.5.js"></script>
<form
class="mailing-list seva-form formkit-form"
action="https://app.convertkit.com/forms/6549537/subscriptions"
action="https://app.convertkit.com/forms/{{ $formId }}/subscriptions"
method="post"
data-sv-form="6549537"
data-uid="9157759fce"
data-sv-form="{{ $formId }}"
data-uid="{{ .uid | default "9157759fce" }}"
data-format="inline"
data-version="5"
data-options='{{ $dataOptions }}'
>
<div data-style="clean">
<ul class="formkit-alert formkit-alert-error" data-element="errors" data-group="alert"></ul>
<div data-element="fields" data-stacked="false">
<label for="mailing-list-email">Get weekly posts in your mailbox</label>
<label for="mailing-list-email">{{ .email_label | default "Get weekly posts in your mailbox" }}</label>
<input
id="mailing-list-email"
name="email_address"
Expand All @@ -45,11 +46,29 @@
required=""
type="email"
>
<button data-element="submit">Subscribe</button>
{{- /* Hack: Tag form submitters. Can probably be cleaned up further.
See https://monicalent.com/blog/2020/05/04/tag-and-segment-convertkit-hugo-gatsby/ */}}
{{ if .tag_id }}
<fieldset
data-group="checkboxes"
group="field"
type="Custom"
order="1"
save_as="Tag"
style="display: none"
>
<div data-element="tags-checkboxes" data-group="checkbox">
<input class="formkit-checkbox" type="checkbox" name="tags[]" value="{{ .tag_id }}" checked="checked">
</div>
</fieldset>
{{ end }}
<button data-element="submit">{{ .submit_label | default "Subscribe" }}</button>
</div>
</div>
</form>
{{ if (.show_rss | default true) }}
<div class="footer">
Alternatively, <a href="https://yanirseroussi.com/index.xml">subscribe to RSS feed</a>.
</div>
{{ end }}
</div>
78 changes: 10 additions & 68 deletions layouts/shortcodes/lead_magnet_form.html
Original file line number Diff line number Diff line change
@@ -1,68 +1,10 @@
{{/*
An embeddable lead magnet form. Annoyingly also includes ConvertKit's script, but this will be sorted later.
*/}}
{{
$dataOptions := (dict
"settings" (dict
"after_subscribe" (dict
"action" "message"
"success_message" "Success! Now check your email to get your PDF guide."
"redirect_url" ""
)
"recaptcha" (dict
"enabled" false
)
"return_visitor" (dict
"action" "show"
"custom_content" ""
)
)
"version" "5"
) | jsonify
}}

<div class="mailing-list-container">
<script src="https://f.convertkit.com/ckjs/ck.5.js"></script>
<form
class="mailing-list seva-form formkit-form"
action="https://app.convertkit.com/forms/6554492/subscriptions"
method="post"
data-sv-form="6554492"
data-uid="26c0fa1a04"
data-format="inline"
data-version="5"
data-options='{{ $dataOptions }}'
>
<div data-style="clean">
<ul class="formkit-alert formkit-alert-error" data-element="errors" data-group="alert"></ul>
<div data-element="fields" data-stacked="false">
<label for="mailing-list-email">Get your copy by email today</label>
<input
id="mailing-list-email"
name="email_address"
aria-label="Email address"
placeholder="Email address"
required=""
type="email"
>
{{- /* Hack: Tag form submitters. Can probably be cleaned up further.
See https://monicalent.com/blog/2020/05/04/tag-and-segment-convertkit-hugo-gatsby/ */}}
<fieldset
data-group="checkboxes"
class="formkit-7572"
group="field"
type="Custom"
order="1"
save_as="Tag"
style="display: none"
>
<div data-element="tags-checkboxes" data-group="checkbox">
<input class="formkit-checkbox" id="tag-7572-5001948" type="checkbox" name="tags[]" value="5001948" checked="checked">
<label for="tag-7572-5001948">Data-to-AI Health Check Downloaders</label>
</div>
</fieldset>
<button data-element="submit">Submit</button>
</div>
</div>
</form>
</div>
{{- partial "subscribe_form.html" (dict
"context" .
"email_label" "Get your copy by email today"
"form_id" 6554492
"show_rss" false
"submit_label" "Submit"
"success_message" "Success! Now check your email to get your PDF guide."
"tag_id" 5001948
"uid" "26c0fa1a04"
) }}
2 changes: 1 addition & 1 deletion layouts/shortcodes/subscribe_form.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{- partial "subscribe_form.html" . }}
{{- partial "subscribe_form.html" (dict "context" .) }}

0 comments on commit ee4cddc

Please sign in to comment.