bjacquemet / personal-web

Hugo Template for Freelancer Portfolio and Blog
MIT License
137 stars 107 forks source link

exampleSite content references non existent tweet #8

Closed onedrawingperday closed 4 years ago

onedrawingperday commented 4 years ago

Hello @bjacquemet

I am one of the maintainers of Hugo Themes.

There is a reference to a non existent tweet in the content files of your theme's exampleSite.

ERROR 2020/01/03 17:25:32 Failed to get JSON resource "https://api.twitter.com/1/statuses/oembed.json?hide_thread=1&id=%!s(int=1120412132036706305)&dnt=true": Failed to retrieve remote file: Bad Request

This results in a broken demo on the Hugo Themes website.

I tried to make your theme inherit its content from the hugoBasicExample repo, so that the demo generates.

However this resulted in an empty homepage since your theme has a custom portfolio section and even though you are using Hugo's internal mainSections you have hardcoded the section whose content is displayed on the index page.

To fix the demo you need to remove the reference to the non-existent tweet.

Also note that as stated in the Hugo Themes README:

Theme Maintenance

  • It is of paramount importance that a Hugo theme's demo generates with the latest version of Hugo.

  • Theme authors need to keep an eye on future Hugo releases and provide patches as needed.

  • The Hugo Themes Showcase always uses the latest Hugo version to generate its website.

  • If a theme demo breaks and remains so for more than 30 calendar days, we may remove it from this repository without further notification.

bjacquemet commented 4 years ago

Hi @onedrawingperday thanks very much for the heads up. I wonder why it is resulting in an error on your side. Here is the page containing the tweet deployed with Netlify: https://personal-web-example.netlify.com/post/shortcodes/#add-a-single-tweet The tweet is showing - I deliberately chose an account and tweet that wouldn't be removed

onedrawingperday commented 4 years ago

@bjacquemet

Right. So this ERROR is due to recent Hugo updates.

The external demo is generated with Hugo 0.54.0 but the Hugo website generates always with the latest Hugo currently Hugo 0.62.2.

Your theme's demo has been broken since last October.

Hugo 0.59.0 introduced support for typed bool, int and float values in shortcode params. Also see: https://github.com/gohugoio/hugo/pull/6376

Upon closer inspection the request generated by the tweet shortcode that is used in your theme points to a non-existent URL:

https://api.twitter.com/1/statuses/oembed.json?hide_thread=1&id=%!s(int=1120412132036706305)&dnt=true"

This part in particular:

- %!s(int=1120412132036706305) -

The tweet ID is outputted as an int due to the way that the tweet-single parameter is entered ie.{{< tweet-single 1120412132036706305 >}}

To fix the ERROR you will need to either change the shortcode input so that the tweet ID is a string by wrapping it in quotes like so: {{< tweet-single "1120412132036706305" >}}

OR

I think it is preferable to do this directly within the shortcode by changing line 6 of tweet-single.html to something like the following:

{{- $tweetID := print (index .Params 0) -}}
{{- $url := printf "https://api.twitter.com/1/statuses/oembed.json?hide_thread=1&id=%s&dnt=%t" $tweetID $pc.EnableDNT -}}

Once you issue a fix feel free to close this issue.

bjacquemet commented 4 years ago

Thanks a lot. Fixed in the last commit