summaryrefslogtreecommitdiff
path: root/readme.md
blob: 096145e8240cbe3d5e9bec986e90c9b4a6e86068 (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
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
71
72
# andrefincato.info

javascript is online space of torture. moving from [choo.js / spa](https://github.com/afincato/andrefincato/tree/v4), to txt files and pandoc templates to output self-contained html documents (including css, fonts, and images).

- [basic pandoc-to-html ref](https://bitfragment.net/mindoc/)
- [great ref for html optimization](https://k1ss.org//blog/20191004a)
- [nice guide on using nginx for static websites](https://medium.com/@jgefroh/a-guide-to-using-nginx-for-static-websites-d96a9d034940)

## pandoc build

```
pandoc content/index.txt --template templates/index.html -o dist/index.html -V commit_date="$(git log -n 1 --pretty=format:%cd --date=format:'%Y-%m-%dT%H:%M:%S' -- content/index.txt)" -V commit_hash="$(git log -n 1 --pretty=format:%h -- content/index.txt)"
```

or

```
pandoc content/notfound.txt --resource-path=./content --template=../templates/notfound.html --self-contained -o dist/notfound.html
```

## list file revision

```
git ls-files | grep content | while read -r line ; do git log -1 --pretty=format:"%h" -- $line | xargs -I {} rg {} -l dist/* ; done
```

- get list of files being tracked by git
- grep to get back only the `content` folder
- start a while loop to read each line and assign value to `$line`
- run a command to retrieve the latest git commit (short format, `%h`) of each line (each file)
- take each hash and use it to (rip)grep through the dist folder recursively, and show only the filename of each match

*or*

rather than diffing between the latest hash of a file and grepping for it on it output in `dist` — this assumes that file has been converted to html at least once — take a step back and bind the publishing process more closely to git:

show which files have been changed and in which way (added [A], modified [M], deleted [D])

```
git diff --name-status -- content
```

returns the following

```
M       content/notfound.txt
D       content/test.txt
```

then upon staging and committing, run a post-hook to either convert the file to html or delete the existing file from the dist folder. possibly overall easier?


## updates

### 2020-11-07

- just moved from fully self-contained documents to have link-ref to `assets/styles.css`. 
- still embedding web-fonts with base64 on stylesheet
- the template `notfound`, which has an image, is the only one being converted by pandoc as `--self-contained`, so the images is converted to base64
- things are a bit messy after this change, but as the website is growing a little bit, repeating the same css (by using `<style>`) across several pages began to feel silly
- the build script also should either take a flag options, for when converting as `--self-contained`, or the image should be point to the correct url (and being server as an actual image file)

## refs

- [Converting all files in a folder to md using pandoc on Mac](https://stackoverflow.com/questions/26126362/converting-all-files-in-a-folder-to-md-using-pandoc-on-mac#26304106)
- [Convert any folder into a website using Pandoc and a Makefile](https://computableverse.com/blog/create-website-using-pandoc-make-file)
- [pandoc-bash-blog](https://github.com/bewuethr/pandoc-bash-blog)
- [Find files and execute command](https://stackoverflow.com/questions/26911213/find-files-and-execute-command
- )
- [Is it possible to use `find -exec sh -c` safely?](https://unix.stackexchange.com/questions/156008/is-it-possible-to-use-find-exec-sh-c-safely)
- [How do I assign the output of a command to a variable?](https://askubuntu.com/questions/323162/how-do-i-assign-the-output-of-a-command-to-a-variable)