Summary Files Commits Branches @commit @diff @stats
path: root / ext / meta.awk
blob: 35e4f2b2eba7ac6139b810b41dbc5e5d9c9b75ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
BEGIN {
	FS="\t"
	while ((getline < ENVIRON["META"]) > 0) {
		if ($1 == "") continue
		meta_title[$1] = $2 " &mdash; Syndamia"
		meta_description[$1] = $3
		if (length($3) > 200)
			warning("Description for file \"" $1 "\" is longer than 200 characters!", "Shorten the description field in the \"" ENVIRON["META"] "\" file.")
	}
	FS=" "
}

FNR == 0 {
	STD_FILENAME = substr(FILENAME, length(ENVIRON["GEN_DIR"]) + 2)

	if (STD_FILENAME in meta_title) {
		substitutions["TITLE"] = meta_title[STD_FILENAME]
		substitutions["DESCRIPTION"] = meta_description[STD_FILENAME]
	}
	else {
		delete substitutions["TITLE"]
		delete substitutions["DESCRIPTION"]
	}
}