如何将本地依赖项添加到bookdown-project?

时间:2018-09-20 18:20:15

标签: r r-markdown bookdown

我试图弄清楚如何在我的bookdown-project中添加(本地)库,例如bootstrap。阅读this reply后,我尝试了以下操作:

# set dependencies with htmltools::htmlDependency()
this.dir <- dirname(parent.frame(2)$ofile) # get current direct
setwd(this.dir) # set working directory to current directory
libs.dir <- paste(this.dir,"/libs/", sep = "")

.dependencies <- htmltools::htmlDependency(
  "bootstrap", "4.1.2",
  c(href = paste(libs.dir, "bootstrap-4.1.2", sep = "")),
  script = "bootstrap.min.js",
  stylesheet = "bootstrap.min.css"
)

并将.dependencies添加到index.Rmd的标题中:

--- 
title: "something"
author: "someone"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "something"
output:
  extra_dependencies: .dependencies  ## THIS WON'T WORK?
  bookdown::gitbook:
    self_contained: false
    lib_dir: libs
    split_by: section
    config:
      toolbar:
        position: static
---

我没有收到错误,但是显然它没有用,因为引导依赖项没有显示在libs-dir中。

有人可以指出我正确的方向吗?谢谢

0 个答案:

没有答案