Last active
June 20, 2024 09:23
-
-
Save matt-dray/cda4a3facb6b1ca848a8ddbcc885a669 to your computer and use it in GitHub Desktop.
Make a shields.io README badge that links to a Shiny app, using the {badgr} package in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make a README badge for your R Shiny repo | |
# Matt Dray, March 2021 | |
# {badgr} blog post: https://www.rostrum.blog/2020/05/08/readme-badge/ | |
# Shiny badge blog post: https://www.rostrum.blog/2021/03/23/shiny-badge/ | |
# {badgr} is available from GitHub via {remotes} | |
install.packages("remotes") # if not already installed | |
remotes::install_github("matt-dray/badgr") # install {badgr} | |
# Generate badge URL and wrap in Markdown link | |
badgr::get_badge( | |
# Badge label | |
label = "Shiny", # left-side text | |
label_color = "white", # left-side colour | |
# Badge message | |
message = "shinyapps.io", # right-side text | |
color = "447099", # right-side colour, hex (no hashmark) | |
# Logo | |
logo_simple = "Posit", # named icon from simpleicons.org | |
logo_color = "447099", # could also used named colours for colours | |
# Markdown link | |
md_link = "https://mattdray.shinyapps.io/randoflag/", # clickable link URL | |
# Convenience arguments | |
browser_preview = TRUE, # preview badge in your browser | |
to_clipboard = TRUE # copies markdown to paste into readme | |
) | |
# Paste into your README, or any other (R) Markdown docs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code above generates this markdown and copies it to your clipboard ready for pasting in a README:
[](https://mattdray.shinyapps.io/randoflag/)
Which renders like this:
That might be showing in green on the right-hand side, but the colour renders correctly on GitHub README.md files for some reason. Alternatively, change the
color
argument to"blue"
.