Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] - Social links/parameters should support the full URL #350

Closed
mattstratton opened this issue Apr 7, 2021 · 21 comments · Fixed by #368
Closed

[ENHANCEMENT] - Social links/parameters should support the full URL #350

mattstratton opened this issue Apr 7, 2021 · 21 comments · Fixed by #368

Comments

@mattstratton
Copy link
Owner

mattstratton commented Apr 7, 2021

For several reasons, including consistency (or social networks changing their URL patterns, etc) all the social links (for both guest/host as well as the params for the site) should support the existing pattern of "name of profile" but also the full URL to the profile as valid input.

We can do that thing where if the value starts with "http" then pass it direct, and if not, transform it.

Connected to #348

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton I'm gonna sit down and look at this now. So i converted the LinkedIn block to this:

        {{ if (isset .Site.Params.social "linkedin" ) }}
          <li>
            {{ $parsedLinkedinUrl := urls.Parse $.Site.Params.social.linkedin }}
            {{ if gt (len $parsedLinkedinUrl.Scheme) 0 }}
              <a class = "social-links" href="{{ .Site.Params.social.linkedin }}"><i class="fab fa-linkedin fa-2x"></i></a>
            {{ else }}
              <a class = "social-links" href="https://www.linkedin.com/in/{{ .Site.Params.social.linkedin }}/"><i class="fab fa-linkedin fa-2x"></i></a>
            {{ end }}
          </li>
        {{ end }}

I couldn't find any existing helper function that was more graceful than this. I could try to write one that can be reused for all the social links, do you think this is the right path?

@mattstratton
Copy link
Owner Author

I think that would work! I feel like I did this similar type thing in another Hugo project but I can't remember exactly where I did it, so if you want to pop in a PR with this for the social links, I'd review it quickly and get it released!

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton Should I make it as a shortcode?

@mattstratton
Copy link
Owner Author

Shortcode won't work; you can only use shortcodes in markdown/content files, not templates.

I think the issue is that we display social links in a couple templates, and since we are writing in Go template but not Go proper, we can't really make functions. Etc.

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton OK so should I just do the above kind of expansion for every social param, or should I only do it for LinkedIn for now where its needed to link to a company page? Maybe other ones like youtube and google have the same problem and I just haven't run into it yet.

@mattstratton
Copy link
Owner Author

Exactly - I wanted to do it for all of the parameters mostly because that makes it easier for folks to not have to remember if that parameter is the full URL or just the user/org name!

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton Is there any reason to keep the google plus stuff in there? Clicking the link in the sample page shows this:
Screen Shot 2022-02-07 at 2 38 46 PM

@mattstratton
Copy link
Owner Author

Yeah, it's probably long since gone enough that we can remove it :)

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton I was about to dive into changing all of these in all the other places where we generate URLs but I also saw this in REFERENCE.md

"TODO: Remove these parameters from exampleSite, but also add one for the the shortname of the host for linking to host page (optional)"

Do you want me to remove/cleanup anything in the other pages while I'm at it?

@mattstratton
Copy link
Owner Author

Ugh I have to clean that up. Basically the idea is that the Authors support should go away and be replaced with the idea of Host pages, but I don't remember enough of what I meant when I wrote that TODO 😂

@mattstratton
Copy link
Owner Author

Basically right now you can ignore any social urls generated from the authors entry on the config. If that makes sense. It should only be used in jumbotron or sidebar components IIRC.

So basically just the site header, the single episode template, and the guest/host single template (maybe the guest/host list templates too? I forget)

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

OK, a topic for another time. So other partials I need to change to match:

footer_scripts: parse out the twitter handle if the social twitter variable is a full URL
hosts: support full URLs for all the social Params
seo: parse out the twitter and facebook handles if the social twitter and facebook variables are a full URL

And the single episode layout page as well.

Anything else you can think of that I missed?

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

Ah ok guest and hosts I missed I'll do those also.

@mattstratton
Copy link
Owner Author

I think these are the files:

layouts/guest/list.html
layouts/guest/single.html
layouts/episode/single.html
layouts/partials/hosts.html
layouts/partials/header.html

I do wonder if there’s a way we could write a partial for anywhere a list of a person’s social links display (wouldn’t work for guest/list.html or partials/header.html) and pass the reference to it? I’m rusty on how the dot . would work here.

@mattstratton
Copy link
Owner Author

mattstratton commented Feb 7, 2022

I think a partial might work if you pass the variables to it

https://gohugo.io/templates/partials/#variable-scoping

But I don't remember if you can call the same partial more than once in a template. I imagine you can but haven't tried.

Partials are smaller, context-aware components in your list and page templates that can be used economically to keep your templating DRY.

@mattstratton
Copy link
Owner Author

Thanks for this, by the way!

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

Yeah I have it working, it took having to pass a dict into the partial so i can pass multiple parameters as shown here:

https://flaviocopes.com/hugo-partial-multiple-parameters/

How do you pass multiple parameters to a partial in Hugo? It's not as simple as it seems, you need to use a trick. Let's find out.

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

@mattstratton why is facebook the only one in this list that has class = nav-item?

https://github.com/mattstratton/castanet/blob/main/layouts/partials/header.html#L35

GitHub
A podcast-oriented theme for Hugo. Contribute to mattstratton/castanet development by creating an account on GitHub.

@mattstratton
Copy link
Owner Author

Because I suck at coding? Hmm.

It's possible it's not required. It's also possible that changing it would break something weird. I'm on my phone today so I can't test; you can take it out of the FB one and see if it changes anything if you'd like - or keep it in and let's file a follow up issue for me to investigate that.

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

OK I am not a front end guy so the nuances of this CSS stuff escapes me. Seems fine without it though.

@ctindel
Copy link
Contributor

ctindel commented Feb 7, 2022

Okie dokie, its in, let me know if you find any issues in your testing or see something I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants