Skip to content

Commit efb0e1f

Browse files
authored
Rethink directory structure. (#37)
* Rethink directory structure. Only content exists in `src`. Templates, static and assets lives elsewhere. Images now work in both the IDE and website. It's all intutive. * fix curl arg.
1 parent 7a75c6d commit efb0e1f

File tree

15 files changed

+49
-40
lines changed

15 files changed

+49
-40
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ gathers all files not named "index.md" into an RSS feed.
1616

1717
This tool is configurable by environment variables.
1818

19-
| Variable | Description | Default |
20-
|-----------|-----------------------------------------------------|--------------------|
21-
| `SRC` | Root directory of input sources. | `src/` |
22-
| `DST` | Root directory for generated output. | `public/` |
23-
| `STATIC` | Directory for static assets. | `$SRC/static` |
24-
| `SRC_EXT` | Input sources file extension. | `md` |
25-
| `DST_EXT` | Output generation file extension. | `html` |
26-
| `HEADER` | path/to/header.html (`--include-before-body`). | `$SRC/header.html` |
27-
| `FOOTER` | path/to/footer.html (`--include-after-body`). | `$SRC/footer.html` |
28-
| `CSS` | path/to/style.css embedded in header of a web page. | `/main.css` |
29-
| `PANOPTS` | Arguments to pass to Pandoc for each input file. | `--css $CSS --metadata-file=$ROOT/defaults.yml -B $HEADER -A $FOOTER` |
19+
| Variable | Description | Default |
20+
|-----------|-----------------------------------------------------|--------------------------------------------------------------------------------------|
21+
| `SRC` | Root directory of input sources. | `src/` |
22+
| `DST` | Root directory for generated output. | `public/` |
23+
| `ASSETS` | Directory to store media, like images | `assets/` |
24+
| `STATIC` | Directory for static site assets, like CSS files. | `$SRC/static/` |
25+
| `SRC_EXT` | Input sources file extension. | `md` |
26+
| `DST_EXT` | Output generation file extension. | `html` |
27+
| `HEADER` | path/to/header.html (`--include-before-body`). | `template/header.html` |
28+
| `FOOTER` | path/to/footer.html (`--include-after-body`). | `template/footer.html` |
29+
| `CSS` | path/to/style.css embedded in header of a web page. | `css/main.css` |
30+
| `PANOPTS` | Arguments to pass to Pandoc for each input file. | `--css $CSS --metadata-file=$ROOT/defaults.yml -B $HEADER -A $FOOTER" -V lang=en-US` |
3031

3132
To make it easier to edit metadata for every page, consider making changes to the `defaults.yml` at the project root.
3233

@@ -41,6 +42,8 @@ for more inspiration.
4142

4243
`bin/watch` will watch the source directory. On any changes, it will invoke the build script.
4344

45+
> Note: if you change files outside of `$SRC` (i.e. in `template/` or `static/`), you'll need to terminate and
46+
> re-run this script.
4447
4548
### Deployment
4649

assets/birth-aging-dying.webp

669 KB
Binary file not shown.

assets/kraftwerk.webp

228 KB
Binary file not shown.

bin/build

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,17 @@ convert() {
3737
pandoc $PANOPTS "$file" --output="$DST$TO" || warn "Failed to create $TO"
3838
}
3939

40-
copy() {
41-
file="$1"
42-
FROM=$file
43-
TO="$DST${file##"$STATIC"}"
44-
echo "${FROM##"$ROOT"} --> ${TO##"$ROOT"}"
45-
mkdir -p "$(dirname "$TO")"
46-
cp "$FROM" "$TO" || warn "Failed to copy asset $TO"
47-
}
48-
4940
status "Rendering"
5041
find "$SRC" -type f -name "*.$SRC_EXT" | while IFS= read -r file; do
5142
convert "$file" &
5243
done
5344
wait
5445

46+
status "Copying over static"
47+
cp -r "$STATIC/"* "$DST"
48+
5549
status "Copying over assets"
56-
find "$STATIC" -type f | while IFS= read -r file; do
57-
copy "$file" &
58-
done
59-
wait
50+
cp -r "$ASSETS" "$DST"
6051

6152
status "Rendering RSS feed"
6253
# This does the following:
@@ -72,7 +63,7 @@ echo "$ORDERED_POSTS"
7263
# shellcheck disable=SC2086
7364
pandoc-rss -s \
7465
-t "My Pandoc Blog" \
75-
-d "A blog built with Pandaoc" \
66+
-d "A blog built with Pandoc" \
7667
-l "https://github.com/alxmrs/pandoc-website-template" \
7768
-f "%s/" \
7869
-c "MIT or CC BY-SA 4.0" \

bin/env

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
#
33
# Environment variables, with defaults.
44
#
55
ROOT=$(dirname "$(dirname "$(realpath "$0")")")
66
SRC=${SRC:-"$ROOT/src"}
77
DST=${DST:-"$ROOT/public"}
8-
STATIC=${STATIC:-"$SRC/static"}
9-
HEADER=${HEADER:-"$SRC/header.html"}
10-
FOOTER=${FOOTER:-"$SRC/footer.html"}
8+
ASSETS=${ASSETS:="$ROOT/assets"}
9+
STATIC=${STATIC:-"$ROOT/static"}
10+
HEADER=${HEADER:-"$ROOT/template/header.html"}
11+
FOOTER=${FOOTER:-"$ROOT/template/footer.html"}
1112
CSS=${CSS:-"/css/main.css"}
1213
SRC_EXT=${SRC_EXT:-"md"}
1314
DST_EXT=${DST_EXT:-"html"}
14-
PANOPTS=${PANOPTS:-"--css $CSS --metadata-file=$ROOT/defaults.yml -B $HEADER -A $FOOTER"}
15+
PANOPTS=${PANOPTS:-"--css $CSS --metadata-file=$ROOT/defaults.yml -B $HEADER -A $FOOTER" -V lang=en-US}

bin/install

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
set -e
33
#
44
# Install pandoc on debian.
55
#
6-
7-
curl -O -L -C - https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb
8-
sudo dpkg -i pandoc-2.19.2-1-amd64.deb
9-
rm pandoc-2.19.2-1-amd64.deb
6+
VERSION="3.6.3"
7+
curl -o pandoc.deb -L -C - "https://github.com/jgm/pandoc/releases/download/$VERSION/pandoc-$VERSION-1-amd64.deb"
8+
sudo dpkg -i pandoc.deb
9+
rm pandoc.deb
1010

1111
#
1212
# Install pandoc-rss on debian.

bin/logging

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
#
33
# Constants & functions for logging.
44
#

bin/watch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
#
33
# Watch $SRC, re-build when any file changes.
44
#

defaults.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
lang: en-US
2-
from: gfm+raw_html
3-
to: html
1+
header-includes:
2+
- <meta property="og:image" content="/assets/kraftwerk.webp">
File renamed without changes.

src/blog/index.md renamed to src/blog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
title: Blog
33
---
44

5+
## 2025
6+
- [Cool museum](/cool-museum/)
7+
58
## 2023
69
- [Can't Stop Blogging](/cant-stop-blogging/)
710
- [New Blog](/new-blog/)

src/cool-museum.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Contemporary Art in Bangkok!
3+
date: 2025-03-08
4+
---
5+
6+
I love this painting I saw on my trip to Thailand!
7+
8+
![Birth, Aging, Dying](/assets/birth-aging-dying.webp)

src/static/css/main.css renamed to static/css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ nav ul li {
2323
margin-right: 20px;
2424
line-height: 2.5em;
2525
}
26+
27+
img {
28+
max-width: 95%;
29+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)