Skip to content

Commit

Permalink
feat: add contact form
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Sep 13, 2023
1 parent efc71fc commit 32cd8b0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/pages/contact.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div>
<h1>{{ t('title') }}</h1>
<form data-static-form-name="contact">
<div>
<label>{{ t('name') }}<input type="text" name="name" /></label>
</div>
<div>
<label>{{ t('email') }}<input type="email" name="email" /></label>
</div>
<div>
<label>{{ t('message') }}<textarea name="message"></textarea></label>
</div>
<button type="submit">{{ t('send') }}</button>
</form>
</div>
</template>

<script setup lang="ts">
const { t } = useI18n()
</script>

<i18n lang="yaml">
de:
email: E-Mail-Adresse
message: Nachricht
name: Name
send: Senden
title: Kontakt
en:
email: Email address
message: Message
name: Name
send: Send
title: Contact
</i18n>
17 changes: 17 additions & 0 deletions src/public/functions/_middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mailchannelsPlugin from '@cloudflare/pages-plugin-mailchannels'

export const onRequest = mailchannelsPlugin({
personalizations: [
{
to: [
{ name: 'Jonas Thelemann', email: 'e-mail+form@jonas-thelemann.de' },
],
},
],
from: { name: 'jonas-thelemann.de', email: 'no-reply@cloudflare.com' },
respondWith: () =>
new Response(null, {
status: 302,
headers: { Location: '/thank-you' },
}),
})

0 comments on commit 32cd8b0

Please sign in to comment.