-
Notifications
You must be signed in to change notification settings - Fork 113
/
redirect.R
65 lines (58 loc) · 1.66 KB
/
redirect.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
56
57
58
59
60
61
62
63
64
65
install.packages("fs")
install.packages("yaml")
redirects <- yaml::read_yaml("_output.yml")$redirects
make_redirect <- function(from, to){
html <- sprintf(
'<head><meta http-equiv="refresh" content="0; URL=%s.html" /></head>',
to
)
dest <- fs::path("_site", from, ext = "html")
fs::file_create(dest)
write(html, dest)
}
mapply(make_redirect, from = names(redirects), to = redirects)
# Creating the redirect
unlink("redirects", TRUE, TRUE)
make_redirect <- function(name, url){
fs::dir_create(
fs::path(
"redirects",
name
)
)
fls <- fs::path(
"redirects",
name,
"index.html"
)
fs::file_create(
fls
)
write(file = fls,
sprintf('<head><meta http-equiv="refresh" content="0; URL=%s" /></head>', url)
)
}
make_redirect("tidytuesday201942", "https://connect.thinkr.fr/tidytuesday201942/")
make_redirect("hexmake", "https://connect.thinkr.fr/hexmake/")
make_redirect("minifying", "https://connect.thinkr.fr/minifying/")
make_redirect("golemhtmltemplate", "https://connect.thinkr.fr/golemhtmltemplate/")
make_redirect("shinipsumdemo", "https://connect.thinkr.fr/shinipsumdemo/")
make_redirect("databasedemo", "https://connect.thinkr.fr/databasedemo/")
make_redirect("graysacle", "https://connect.thinkr.fr/grayscale/")
make_redirect("grayscale", "https://connect.thinkr.fr/grayscale/")
make_redirect("bs4dashdemo", "https://connect.thinkr.fr/bs4dashdemo/")
make_redirect("shinyfuture", "https://connect.thinkr.fr/shinyfuture/")
try({
dirs <- list.dirs(
"redirects"
)
dirs <- dirs[!dirs == "redirects"]
for (i in c(
dirs
)){
fs::dir_copy(
i,
fs::path("_site", basename(i))
)
}
})