-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.Rmd
executable file
·55 lines (49 loc) · 1.41 KB
/
index.Rmd
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
---
output:
html_document:
includes:
in_header: hero-image.html
css: styles.css
---
```{r message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
library(tidyverse)
library(fs)
library(glue)
library(lubridate)
```
```{r message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
all_posts <- dir_tree("posts", glob = "*.html|*.txt") %>%
tibble() %>%
select("file_name" = 1) %>%
separate(
file_name,
c("main_folder", "post_date", "file"),
sep = "/",
remove = FALSE
) %>%
filter(!is.na(file)) %>%
arrange(desc(post_date)) %>%
group_by(file_name) %>%
mutate(
post_description = case_when(
str_detect(file_name, "description.txt") ~ read_file(file_name),
TRUE ~ NA_character_
),
post_title = case_when(
str_detect(file_name, "post_title.txt") ~ read_file(file_name),
TRUE ~ NA_character_),
post_date = format(ymd(post_date), format = '%b %d, %Y' )
) %>%
group_by(post_date) %>%
fill(c(post_description, post_title), .direction = "downup") %>%
filter(str_detect(file_name, ".html"))
```
```{r echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE, results='asis'}
glue_data(all_posts,
"<h3><a class='links' href='{file_name}'>{post_title}</a></h3>",
"<h5>{post_date}</h5>",
"<p>{post_description}</p>",
"<a class='btn btn-outline-primary btn-sm' href='{file_name}'>Read More</a>",
"<hr>"
)
```