-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.qmd
71 lines (55 loc) · 1.67 KB
/
index.qmd
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
66
67
68
69
70
---
listing:
contents: posts
feed: true
sort-ui: true
sort:
- "date desc"
- "title desc"
type: default
image-height: 150px
image-placeholder: "themockup.png"
fields: [image, title, description, date, reading-time]
categories: true
date-format: "YYYY-MM-DD"
page-size: 9
toc: false
toc-location: body
page-layout: full
title-block-banner: false
---
Want to support my blog? <a href="https://www.buymeacoffee.com/thomasmock" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-blue.png" alt="Buy Me A Coffee" height="30"></a>
<a rel="me" href="https://fosstodon.org/@thomas_mock"></a>
```{r write-redirects}
#| echo: false
# list names of post folders,
# adapted from Dr. Danielle Navarro,
# a legit Data Witch
# https://blog.djnavarro.net/porting-to-quarto/#netlify-redirects
posts <- list.dirs(
path = here::here("posts"),
full.names = FALSE,
recursive = FALSE
)
# extract the slugs
slugs <- stringr::str_remove(posts, "\\d{4}-\\d{2}-\\d{2}-(?!\\d)")
# lines to insert to a netlify _redirect file
redirects <- paste0("/", slugs, " ", "/posts/", posts)
# write the _redirect file
writeLines(redirects, here::here("_site", "_redirects"))
```
```{r write-tags}
#| echo: false
library(rvest)
library(xml2)
raw_html <- read_html(here::here("_site/index.html"))
length_tags <- raw_html |>
html_nodes("#quarto-margin-sidebar > div > div") |>
length()
all_tags <- sapply(seq_len(length_tags), function(x){
html_nodes(raw_html, xpath = glue::glue('//*[@id="quarto-margin-sidebar"]/div/div[{x}]/text()')) |>
html_text(trim = TRUE)
})
all_tags[all_tags != "All"] |>
readr::write_lines(here::here("_data/unique_categories.txt"))
```