Title: | GOV.UK Style Templates for R Markdown |
---|---|
Description: | A suite of custom R Markdown formats and templates for authoring web pages styled with the GOV.UK Design System. |
Authors: | Crown Copyright 2019 [cph], Duncan Garmonsway [aut, cre] |
Maintainer: | Duncan Garmonsway <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.10.1 |
Built: | 2024-11-12 04:40:55 UTC |
Source: | https://github.com/ukgovdatascience/govdown |
A template for rendering R Markdown documents as HTML using the GOV.UK Design System. Can be used for single documents or for websites. font: "sans-serif" favicon: "custom" logo: "images/govdown-logo-white-on-transparent.svg" logo_url: "index.html" logo_text: "govdown" page_title: "page_title" title: "title" phase: alpha feedback_url: "https://github.com/ukgovdatascience/govdown/issues"
govdown_document( keep_md = FALSE, font = c("sans-serif", "new-transport"), favicon = c("none", "custom", "govuk"), logo = FALSE, logo_url = "", logo_text = "Logo text", page_title = "Page title", title = "Title", phase = c("none", "alpha", "beta"), feedback_url = "404.html", google_analytics = NULL, ... )
govdown_document( keep_md = FALSE, font = c("sans-serif", "new-transport"), favicon = c("none", "custom", "govuk"), logo = FALSE, logo_url = "", logo_text = "Logo text", page_title = "Page title", title = "Title", phase = c("none", "alpha", "beta"), feedback_url = "404.html", google_analytics = NULL, ... )
keep_md |
logical, whether to keep the intermediate |
font |
one of |
favicon |
one of
See |
logo |
|
logo_url |
URL to follow when the logo is clicked. |
logo_text |
Text to place beside the logo. |
page_title |
Text to go inside the |
title |
Text to appear in the main part of the bar at the top of every page. |
phase |
one of |
feedback_url |
URL for feedback, given in the phase banner when |
google_analytics |
Google Analytics ID for monitoring traffic to the website. |
... |
passed on to |
To configure a standalone document, use the yaml at the top of the .Rmd
file.
--- output: govdown::govdown_document: font: "sans-serif" favicon: "custom" logo: "images/logo.svg" logo_url: "https://ukgovdatascience.github.io/govdown/" logo_text: "logo_text" page_title: "page_title" title: "title" phase: alpha feedback_url: "https://github.com/ukgovdatascience/govdown/issues" google_analytics: "UA-12345678-90" ---
To configure a website, use a _site.yml
file instead.
output_dir: docs # to host on GitHub pages navbar: - text: "Home" href: index.html - text: "Tech docs" href: tech-docs.html - text: "News" href: NEWS.html output: govdown::govdown_document: font: "sans-serif" favicon: "custom" logo: "images/govdown-logo-white-on-transparent.svg" logo_url: "index.html" logo_text: "govdown" page_title: "page_title" title: "title" phase: alpha feedback_url: "https://github.com/ukgovdatascience/govdown/issues" google_analytics: "UA-45097885-11"
R Markdown output format to pass to rmarkdown::render()
## Not run: # Requires pandoc version 2+ input_rmd <- system.file("extdata/input.Rmd", package = "govdown") x <- rmarkdown::render(input_rmd, govdown_document()) y <- rmarkdown::render(input_rmd, govdown_document(phase = "alpha")) utils::browseURL(x) utils::browseURL(y) ## End(Not run)
## Not run: # Requires pandoc version 2+ input_rmd <- system.file("extdata/input.Rmd", package = "govdown") x <- rmarkdown::render(input_rmd, govdown_document()) y <- rmarkdown::render(input_rmd, govdown_document(phase = "alpha")) utils::browseURL(x) utils::browseURL(y) ## End(Not run)
If your page renders weirdly, it might be because a crosstalk component like
crosstalk::filter_select()
is injecting unexpected css into
your page, which happens because they try to use the Bootstrap css library by
default. The unstrap()
function prevents that from happening.
unstrap(x)
unstrap(x)
x |
a crosstalk component, such as |
The component x
but with any "boostrap"
dependency removed from its
html_dependencies
attribute.
# The fs object will inject css into your page. if (requireNamespace("crosstalk", quietly = TRUE)) { df <- crosstalk::SharedData$new(mtcars) fs <- crosstalk::filter_select( id = "myselector", label = "select something", sharedData = df, group = ~cyl ) # The fs_nobootstrap object won't inject css into your page. fs_nobootstrap <- unstrap(fs) }
# The fs object will inject css into your page. if (requireNamespace("crosstalk", quietly = TRUE)) { df <- crosstalk::SharedData$new(mtcars) fs <- crosstalk::filter_select( id = "myselector", label = "select something", sharedData = df, group = ~cyl ) # The fs_nobootstrap object won't inject css into your page. fs_nobootstrap <- unstrap(fs) }