First Worker for Hugo Website on Pages

Hello. I have a stupid newbie question. I’ve created a few Hugo websites using Pages. I’ve never used a Cloudflare Worker though. I’m wanting to add a “contact us” form so visitors can email me. I’ve read over helpful post: " Send email using Workers with MailChannels" from May. I added the /functions/_middleware.ts file and used the HTML code to make the actual form. My question is how do I make the actual worker function. Do I just copy and paste the first block of code in the article into the worker? Like I said, I’ve never used a worker before, so I’m clueless.