File tree Expand file tree Collapse file tree 2 files changed +24
-24
lines changed
Expand file tree Collapse file tree 2 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -100,8 +100,8 @@ rssFeed: 'https://rss.flightcast.com/w7bqgc792i30fd43a32uawx0.xml';
100100#### Setting up the contact form
101101
102102The contact form hits an APIRoute at ` /api/contact ` . It is currently configured
103- to send the form data to a Slack channel webhook I had setup . It reads the url
104- from ` import.meta.env.SLACK_WEBHOOK ` , so if you define a ` SLACK_WEBHOOK `
103+ to send the form data to a Discord channel webhook. It reads the url from
104+ ` import.meta.env.DISCORD_WEBHOOK ` , so if you define a ` DISCORD_WEBHOOK `
105105environment variable it should work for you. Of course, feel free to customize
106106the code [ here] ( ./src/pages/api/contact.ts ) to send the data elsewhere as you
107107see fit.
Original file line number Diff line number Diff line change @@ -18,34 +18,34 @@ export const POST: APIRoute = async ({ request }) => {
1818 ) ;
1919 }
2020
21- await fetch ( import . meta. env . SLACK_WEBHOOK , {
21+ await fetch ( import . meta. env . DISCORD_WEBHOOK , {
2222 method : 'POST' ,
2323 headers : {
24- Accept : 'application/json' ,
2524 'Content-Type' : 'application/json'
2625 } ,
2726 body : JSON . stringify ( {
28- blocks : [
27+ embeds : [
2928 {
30- type : 'section' ,
31- text : {
32- type : 'mrkdwn' ,
33- text : `*Name:* ${ name } `
34- }
35- } ,
36- {
37- type : 'section' ,
38- text : {
39- type : 'mrkdwn' ,
40- text : `*Email:* ${ email } `
41- }
42- } ,
43- {
44- type : 'section' ,
45- text : {
46- type : 'mrkdwn' ,
47- text : `*Message:* ${ message } `
48- }
29+ title : 'New Contact Form Submission' ,
30+ color : 0x5865f2 ,
31+ fields : [
32+ {
33+ name : 'Name' ,
34+ value : String ( name ) ,
35+ inline : true
36+ } ,
37+ {
38+ name : 'Email' ,
39+ value : String ( email ) ,
40+ inline : true
41+ } ,
42+ {
43+ name : 'Message' ,
44+ value : String ( message ) ,
45+ inline : false
46+ }
47+ ] ,
48+ timestamp : new Date ( ) . toISOString ( )
4949 }
5050 ]
5151 } )
You can’t perform that action at this time.
0 commit comments