get_quarto_source: Get the source URL for a Quarto post

View source: R/quarto.R

get_quarto_sourceR Documentation

Get the source URL for a Quarto post

Description

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

Usage

get_quarto_source(
  repo = "taylordunn/tdunn-quarto",
  branch = "main",
  collection = "posts",
  date = NULL,
  slug = NULL,
  html_tag = TRUE,
  html_label = "Source code",
  renv_link = TRUE
)

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 notebook parameter via params$date.

slug

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

html_tag

Logical. If TRUE (default), returns a HTML hyperlink tag.

html_label

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

renv_link

Logical. If TRUE (default), also returns a link to an renv.lock file.

Value

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

Examples


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

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

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