aboutsummaryrefslogtreecommitdiff
path: root/rss/genrss
blob: 7cfd00525283f9aa78bf49e5db01f273e7493890 (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
#!/bin/sh

cd $(dirname $0)

# exit if no out dir
[[ ! -d ../out ]] && exit 1

cp base.xml atom.xml
for file in ../out/post/*; do
	base=$(basename "$file" .html)

	xml ed -L \
		-s '/rss/channel' -t elem -n item \
		--var newitem '$prev' \
		-s '$newitem' -t elem -n title -v "$(../scripts/meta title "../posts/${base}.md" | jq --raw-output)" \
		-s '$newitem' -t elem -n guid -v "$base" \
		-s '$newitem' -t elem -n link -v "/post/$base" \
		-s '$newitem' -t elem -n pubDate -v "$(../scripts/meta date "../posts/${base}.md" | jq --raw-output)" \
		-s '$newitem' -t elem -n description -v "$(pup -f "../out/post/${base}.html" .contentWrapper)" \
		atom.xml
done

mv atom.xml ../public

cd ..
npx next build
npx next export