-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathredirects.R
More file actions
42 lines (35 loc) · 1.66 KB
/
Copy pathredirects.R
File metadata and controls
42 lines (35 loc) · 1.66 KB
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
redirects <- tibble::tribble(
# backing out of the pattern where I used uppercase filenames to indicate
# chapters that had been revised for 2e
~from, ~to,
"Code.html", "/code.html",
"Data.html", "/data.html",
"Introduction.html", "/introduction.html",
"Metadata.html", "/metadata.html",
"Package-within.html", "/package-within.html",
"Preface.html", "/preface.html",
"Setup.html", "/setup.html",
"Structure.html", "/structure.html",
"Whole-game.html", "/whole-game.html",
"Workflow101.html", "/workflow101.html",
# chapters removed
"git.html", "/software-development-practices.html",
"src.html", "/preface.html",
# 1e -> 2e move, then another move during 2e development
"package.html", "/package-structure-state.html",
"package-structure-state.html", "/structure.html",
# 1e -> 2e move
"check.html", "/workflow101#sec-workflow101-r-cmd-check",
# chapter got merged into another
"inst.html", "/misc.html#inst",
# lots of 1e -> 2e changes and churn within 2e
"namespace.html", "/dependencies-mindset-background.html#sec-dependencies-namespace",
# split into multiple chapters
"tests.html", "/testing-basics.html"
)
redirects$html <- sprintf(
"<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=%s\" /></head></html>",
redirects$to
)
redirects$path <- file.path("_redirects", redirects$from)
purrr::walk2(redirects$html, redirects$path, writeLines)