Skip to content

Commit

Permalink
fix #701: provide username to the tweet shortcodes gohugoio/hugo@0c…
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed May 6, 2022
1 parent e046508 commit 3c1ea2c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: blogdown
Title: Create Blogs and Websites with R Markdown
Version: 1.9.3
Version: 1.9.4
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Adapted to some breaking changes in the wowchemy academic theme again (thanks, @bjsmith, #704). As mentioned in [**blogdown** v1.4](https://github.com/rstudio/blogdown/releases/tag/v1.4), we recommend **blogdown** users to consider using the [hugo-apero](https://github.com/hugo-apero/hugo-apero) theme when creating new sites. This theme is maintained by **blogdown** authors and much more stable.

- Updated documentation to mention that the `tweet` shortcode (or the R wrapper function `blogdown::shortcode('tweet')`) will require the Twitter username for Hugo >= v0.89.0. Previously only the tweet ID is required, e.g., `{{< tweet 852205086956818432 >}}`, but now it also requires the user, e.g., `{{< tweet user="jtleek", id="852205086956818432" >}}` (thanks, @lcolladotor, #701).

# CHANGES IN blogdown VERSION 1.9

## NEW FEATURES
Expand Down
5 changes: 3 additions & 2 deletions R/hugo.R
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,9 @@ hugo_server_args = function(host, port) {
#' @export
#' @examples library(blogdown)
#'
#' shortcode('tweet', '1234567')
#' shortcodes('tweet', as.character(1:5)) # multiple tweets
#' shortcode('tweet', user='SanDiegoZoo', id='1453110110599868418')
#' # multiple tweets (id's are fake)
#' shortcodes('tweet', user='SanDiegoZoo', id=as.character(1:5))
#' shortcode('figure', src='/images/foo.png', alt='A nice figure')
#' shortcode('highlight', 'bash', .content = 'echo hello world;')
#'
Expand Down
8 changes: 5 additions & 3 deletions docs/02-hugo.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,18 @@ knitr::include_graphics('images/jtleek-tweet.png')
If you use the shortcode, all you need in the Markdown source document is:
```go
{{< tweet 852205086956818432 >}}
{{< tweet user="jtleek", id="852205086956818432" >}}
```
Basically, you only need to pass the ID of the tweet to a shortcode named `tweet`. Hugo will fetch the tweet automatically and render the HTML snippet for you. For more about shortcodes, see https://gohugo.io/extras/shortcodes/.
Basically, you only need to pass the username and ID of the tweet to a shortcode named `tweet`.^[Before Hugo v0.89.0, you only need to pass the ID. Since Twitter has started to require the username since late 2021, this means that you have to use Hugo >= 0.89.0 and provide the username if you want to use the Twitter shortcode. For older versions of Hugo, the shortcodes will be broken, unfortunately.] Hugo will fetch the tweet automatically and render the HTML snippet for you. For more about shortcodes, see https://gohugo.io/extras/shortcodes/.
Shortcodes are supposed to work in plain Markdown documents only. To use shortcodes in R Markdown instead of plain Markdown, you have to call the function `blogdown::shortcode()`, e.g.,
````markdown
`r ''````{r echo=FALSE}
blogdown::shortcode('tweet', '852205086956818432')
blogdown::shortcode(
"tweet", user = "jtleek", id = "852205086956818432"
)
```
````
Expand Down
5 changes: 3 additions & 2 deletions man/shortcode.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3c1ea2c

Please sign in to comment.