Skip to content

Instantly share code, notes, and snippets.

@maelle
Created February 16, 2022 13:04
Show Gist options
  • Save maelle/278d2424baa118467960d463d745f083 to your computer and use it in GitHub Desktop.
Save maelle/278d2424baa118467960d463d745f083 to your computer and use it in GitHub Desktop.
glitter-redirect
pkgdown_site_folder <- "glitter"
glitter_redirect <- function() {
'<html>
<head>
<meta http-equiv="refresh" content="0;URL=https://lvaudor.github.io/glitter/" />
<script language="javascript">
window.location.href = "https://lvaudor.github.io/glitter/"
</script>
</head>
</html>'
}
replace_one_html <- function(path) {
message(sprintf("Rewriting %s!", path))
brio::writeLines(glitter_redirect(), path)
}
all_html <- fs::dir_ls(
pkgdown_site_folder,
recurse = TRUE,
glob = "*.html"
)
purrr::walk(all_html, replace_one_html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment