-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-home.R
55 lines (36 loc) · 1.39 KB
/
build-home.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Important is:
# remotes::install_github("r-lib/[email protected]", force = TRUE, upgrade = "never")
# remotes::install_github("r-lib/pkgdown", force = TRUE, upgrade = "never")
# The actual dev version of pkgdown don't detect index.Rmd as a homepage
#
# pkgdown:::build_home_index
try(fs::file_delete("docs/extra.css"))
fs::file_copy("pkgdown/extra.css", new_path = "docs/extra.css")
pkgdown::build_home()
try(fs::file_delete("pkgdown/index.html"))
rmarkdown::render("pkgdown/index.Rmd")
title <- '<div id="brand" class="page-header"><img src="logo.png" width ="15%"/> h|1i|0g|3h|2c|1h|2a|1r|3t|2e|1r|2{rpackage}</div>'
index <- read_lines("docs/index.html")
indx1 <- which(str_detect(index, "<div class=\"contents col-md-9\">"))
indx1
indx2 <- which(str_detect(index, "id=\"installation\""))
indx2
index_new <- read_lines("pkgdown/index.html")
scripts <- str_subset(index_new, "index_files")
scripts <- str_subset(scripts, "bootstrap|jquery|tabsets|highlightjs", negate = TRUE)
scripts
index_new1 <- which(str_detect(index_new, "<p>Highcharter"))
index_new1
index_new2 <- which(str_detect(index_new, "<span></span>"))
index_new2
index_final <- c(
index[1:indx1],
scripts,
title,
index_new[index_new1:index_new2],
index[indx2:length(index)]
)
writeLines(index_final, "docs/index.html")
try(fs::file_delete("docs/index_files/"))
fs::file_move("pkgdown/index_files/", "docs/")
pkgdown::preview_site()