forked from daattali/beautiful-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.R
33 lines (31 loc) · 1.29 KB
/
build.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local({
# fall back on '/' if baseurl is not specified
baseurl = servr:::jekyll_config('.', 'baseurl', '/')
knitr::opts_knit$set(base.url = baseurl)
# fall back on 'kramdown' if markdown engine is not specified
markdown = servr:::jekyll_config('.', 'markdown', 'kramdown')
# see if we need to use the Jekyll render in knitr
if (markdown == 'kramdown') {
knitr::render_jekyll()
} else knitr::render_markdown()
# input/output filenames are passed as two additional arguments to Rscript
a = commandArgs(TRUE)
d = gsub('^_|[.][a-zA-Z]+$', '', a[1])
knitr::opts_chunk$set(
fig.path = sprintf('figure/%s/', d),
cache.path = sprintf('cache/%s/', d)
)
# set where you want to host the figures (I store them in my Dropbox Public
# folder, and you might prefer putting them in GIT)
#if (Sys.getenv('USER') == 'yihui') {
# these settings are only for myself, and they will not apply to you, but
# you may want to adapt them to your own website
#knitr::opts_chunk$set(fig.path = sprintf('%s/', gsub('^.+/', '', d)))
# knitr::opts_knit$set(
# base.dir = '~/Dropbox/Public/jekyll/',
# base.url = 'http://db.yihui.name/jekyll/'
# )
# }
knitr::opts_knit$set(width = 70)
knitr::knit(a[1], a[2], quiet = TRUE, encoding = 'UTF-8', envir = .GlobalEnv)
})