get_distill_source: Get the source URL for a Distill post

View source: R/distill.R

get_distill_sourceR Documentation

Get the source URL for a Distill post

Description

This is a utility function that I use to point to source code on GitHub for my Distill posts, located at https://tdunn.ca/. Credit for the idea goes to Danielle Navarro (https://blog.djnavarro.net/).

Usage

get_distill_source(
  repo = "taylordunn/tdunn",
  branch = "main",
  collection = "_posts",
  date = NULL,
  slug = NULL,
  html_tag = TRUE,
  html_label = "Source code"
)

Arguments

repo

The GitHub repository, "user/repo-name".

branch

Name of the GitHub branch, default "main".

collection

Collection to which the post belongs to, default "_posts".

date

The date of the post. Typically this will be defined as a RMarkdown parameter via params$date.

slug

The URL slug of the post. Typically this will be defined as a RMarkdown parameter via params$slug.

html_tag

Logical. If TRUE, returns a HTML hyperlink tag.

html_label

If returning a HTML hyperlink, the text label to display.

Value

A string of the source code URL, or a HTML hyperlink tag.

Examples


date <- "2021-05-18"
slug <- "tidytuesday-week-21"

get_distill_source(date = date, slug = slug, html_tag = FALSE)
get_distill_source(date = date, slug = slug, html_tag = TRUE)
get_distill_source(date = date, slug = slug, html_tag = TRUE,
                   html_label = "Custom label")

taylordunn/dunnr documentation built on Aug. 8, 2022, 12:28 p.m.