Write HTML output from the site.R file in a site project.
Usage
site_build(dir, file = "site.R", name = "index.html", variables = NULL,
options = list(), bundle_data = FALSE, bundle_package = FALSE,
bundle_libs = FALSE, libs_overwrite = FALSE, libs_base_only = FALSE,
remote_data_handler = TRUE, open_after = FALSE, aggregate = TRUE,
sparse_time = TRUE, force = FALSE, version = "stable", parent = NULL,
include_api = FALSE, endpoint = NULL, tag_id = NULL, serve = FALSE,
host = "127.0.0.1", port = 3000, verbose = TRUE)
site_start_server(dir, host = "127.0.0.1", port = 3000)Arguments
- dir
Path to the site project directory.
- file
Name of the R file to build the site from.
- name
Name of the HTML file to be created.
- variables
A character vector of variable names to include from the data. If no specified, all variables are included.
- options
A list with options to be passed to the site. These will be written to
docs/settings.json, which can be edited by hand.- bundle_data
Logical; if
TRUE, will write the data to the site file; useful when running the site locally without a server (viewing the file directly in a browser). Otherwise, the data will be loaded separately through an http request.- bundle_package
Logical; if
TRUE, will include parts of thedatapackage.jsonfile in thesettings.jsonandindex.htmlfiles. Otherwise, this will be loaded separately through an http request.- bundle_libs
Logical; if
TRUE, will download dependencies to thedocs/libdirectory. This can allow you to run the site offline for all but Leaflet tiles and any remote resources specified infile(such as map shapes) or metadata (such as map overlays).- libs_overwrite
Logical; if
TRUE, will re-download existing dependencies.- libs_base_only
Logical; if
TRUE, will only download the base community dependencies to be served locally.- remote_data_handler
Logical; if
FALSE, will load the data handler script from the site's directory, (which is updated on rebuild) even whenversionis custom. Useful for locally testing an API.- open_after
Logical; if
TRUE, will open the site in a browser after it is built.- aggregate
Logical; if
TRUE, and there is a larger datasets with IDs that partially match IDs in a smaller dataset or that has a map to those IDs, and there are NAs in the smaller dataset, will attempt to fill NAs with averages from the larger dataset.- sparse_time
Logical; if
FALSE, will not trim times from a variable that are all missing.- force
Logical; if
TRUE, will reprocess data even if the source data is older than the existing processed version.- version
Version of the base script and stylesheet:
"stable"(default) for the current stable release,"dev"for the current unstable release, or"local"for a copy of the development files (community.jsandcommunity.css) served fromhttp://localhost:8000. Can also be a URL where files can be found ({version}/community.jsand{version}/community.css).- parent
Directory path or repository URL of a data site from which to use data, rather than using local data.
- include_api
Logical; if
TRUE, will write thedocs/functions/api.jsfile.- endpoint
URL of the served API.
- tag_id
Google tag ID (in the form of
GTM-XXXXXX, wereGTM-might be different depending on the tag type (such asG-orGT-); see https://tagmanager.google.com), which will enables tracking, conditional on thesettings.trackingsetting.- serve
Logical; if
TRUE, starts a local server from the site'sdocsdirectory. Once a server is running, you can usestopAllServersto stop it.- host
The IPv4 address to listen to if
serveisTRUE; defaults to"127.0.0.1".- port
The port to listen on if
serveisTRUE; defaults to 3000.- verbose
Logical; if
FALSE, will not show status messages.
See also
To initialize a site project, use init_site.
Examples
if (FALSE) {
# run from within a site project directory, initialized with `init_site()`
site_build(".")
# serve locally and view the site
site_build(".", serve = TRUE, open_after = TRUE)
}
if (FALSE) {
# serve a site that has already been built
# from the parent directory of a "docs" directory to be served
site_start_server(".")
}