summaryrefslogtreecommitdiff
path: root/src/index.Rmd
blob: b0cd5f78880ae4e91cd7fe0aea7338c6bfdcb33e (plain)
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
---
title: Posts
output:
  html_document:
    css: style.css
---

```{r,echo=FALSE}
library(stringr)

f = list.files(pattern='\\.?md')
f = f[f!='index.Rmd']

get_date = function(filepath){
	ln = grep('date:',readLines(filepath),value=TRUE)
	dt = strsplit(ln, ': ')[[1]][2]
	dt
}

get_title = function(filepath){
	ln = grep('title:',readLines(filepath),value=TRUE)
	t = str_split(ln, ': ', 2)[[1]][2]
	t = gsub("^'","",t)
	t = gsub("'$","",t)
	t
}

dates = sapply(f,FUN=get_date)
titles = sapply(f,FUN=get_title)

filenames = sub('.Rmd','.html',f) 

links = paste('[',titles,'](',filenames,')',sep='')

tab = data.frame(Date=dates,Title=links,row.names=NULL)
tab = tab[order(tab$Date,decreasing=T),]

knitr::kable(tab,row.names=FALSE)

```