EmielH / hallo-hugo

Hallo is a single-page Hugo theme to introduce yourself.
https://themes.gohugo.io/hallo-hugo/
MIT License
102 stars 56 forks source link

Mailform / formspree support? #16

Closed patrickderitter closed 5 years ago

patrickderitter commented 5 years ago

Hi @EmielH, thanks for your work on this Hugo Theme. I was wondering if you'd consider working on contact form support (backed by formspree.io).

Kind regards, Patrick

EmielH commented 5 years ago

Hi @patrickderitter, thanks for using Hello! I hadn't considered it yet, but I'll look into what is needed for this. Of course, feel free to submit a PR if you already know what needs to be done!

patrickderitter commented 5 years ago

Thanks Emiel. I am basically a beginner, but I think I got the Hugo part down in above commit. However, I do not have any feel of designing this, so consider this a starting point.

Let me know your thoughts on the work.

EmielH commented 5 years ago

Thank you very much! I haven't been able to look at the design just yet, but there's something I spotted while going through your code. Because you reuse the e-mail link for Formspree, you make Formspree mandatory for users of this theme. I would like to keep Formspree optional. Someone may want to just include a mailto: link.

Therefore, I'd use separate configuration options for Formspree, and only show the form when they're present. Could you make that change, please? Thanks again!

patrickderitter commented 5 years ago

Hi Emiel. How about this?

EmielH commented 5 years ago

Hi Patrick, my apologies for the late replies; I'm quite busy at the moment.

Your last commit is an improvement in that the form is not mandatory anymore :+1: but I still think the functionality is different enough from the icons that it warrants its very own setting. Also, perhaps other users would like to use other mail form providers in the future, so we need to make sure that existing sites don't break when this is done. I'm thinking something like:

[params.formspree]
  enabled = true
  email = "mail@example.org"

Or maybe, for now, adding it like this is enough:

[params]
  formspree = "mail@example.org"

Another option would be to extend the author information:

[Author]
  name = "John Doe"
  email = "mail@example.org"

and then put

[params]
  formspree = true

or

  formprovider = formspree

somewhere else and have the code for adding the form use the author e-mail address. Although using the author e-mail address looks more "correct" to me, configuring it in this way is a little bit less obvious for the user, I think.

I need to think a bit about which option would be best. What's your opinion?

patrickderitter commented 5 years ago

Hi Emiel, thanks again for your reply.

Another option would be to extend the author information:

[Author]
  name = "John Doe"
  email = "mail@example.org"

I'm a fan of this suggestion :thumbsup:

Thinking about how there are more ways to incorporate mailproviders, I might have a design suggestion. What if we took the email icon in the range .Site.Params.links and let it act differently according to config settings? So when you set a provider (see code below), we use a little magic to show/hide a partial when user clicks on the email icon.

[Author]
    name = "John Doe"
    email = "mail@example.org"

[params]

    [[params.links]]
        iconset = "fas"
        icon = "envelope"
        title = "E-mail"
        provider = "" # can be either blank (for mailto:) or name of provider partial (e.q. formspree)

This way, we add versitility to choose while also making it simple to choose for formspree or even other providers. (I've been contemplating making my own with Azure Functions, but there are other providers as well. It's just that Formspree is the most 'popular' for now)

We can even leave provider out of the exampleSite\config.toml and reference it in the README.

What do you think of this suggestion?

EmielH commented 5 years ago

I like this idea!

I know that some themes use predefined params, e.g. for Twitter, Instagram etc. so that the user can just put their handle in the settings and the theme will do the rest. I chose not to take this approach for this theme because, even though it is convenient, it limits the user: if they want to include a link to a service that I have not thought of, it is not possible to do so. We are going a little bit in this direction by choosing this approach for e-mail.

On the other hand, if we make the provider option point to a partial, or maybe even a page, I see this can be useful for other things as well. I have had requests from people who want to include a page, e.g. to show some projects or to show some copyright information. This could then use the same system.

EmielH commented 5 years ago

Hi @patrickderitter, I just created a new release that adds the option to include additional information. This should make adding a form a lot easier. See the README to find out how it works. It's not the advanced option that we discussed, and requires a bit more work from the user, but it's also much more flexible. Hope this helps! Maybe I'll add the advanced form support option sometime in the future.

patrickderitter commented 5 years ago

Hi @EmielH, I've been really busy and just got around to check this out. I think this is a really neat implementation, enough to suit my needs. I will be implementing it on my own site in production at a later state (because I'm still working on my own formhandler).

Unless you want to keep this open, you can go ahead and close this.

EmielH commented 5 years ago

Alright! :+1: Feel free to submit a PR for the formhandler if you think it would suit the theme!