-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpkgnet_build_gallery.R
37 lines (27 loc) · 1.03 KB
/
pkgnet_build_gallery.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
library(pkgdown)
library(glue)
library(assertthat)
library(rmarkdown)
library(knitr)
##################################################
# This script builds the gallery with pkgdown
# and then replaces relative paths. If this is
# not done, the pkgnet logo link will break and
# the heading spacing will be off.
##################################################
#### Default pkgdown build ####
pkgdown::build_articles(lazy = FALSE)
#### Tweek Paths for CSS, JS, and pkgnet icon paths ######
## Read Page
htmlText <- readLines('./docs/articles/pkgnet-gallery.html')
## Find Lines to Replace
relativePathIx <- grep('(\\.){2}', htmlText)
articlesIx <- grep('(\\.){2}(/articles)', htmlText)
replaceIx <- setdiff(relativePathIx, articlesIx)
## Replace them
htmlText[replaceIx] <- gsub(pattern = '(\\.){2}'
, replacement = 'https://uptake.github.io/pkgnet'
, x = htmlText[replaceIx]
)
## Rebuild Page
writeLines(htmlText, './docs/articles/pkgnet-gallery.html')