40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Check if the file is a 'boilerplate' (i.e. not a post)
|
|
# The return values are designed to be used like this inside a loop:
|
|
# is_boilerplate_file <file> && continue
|
|
#
|
|
# $1 the file
|
|
#
|
|
# Return 0 (bash return value 'true') if the input file is an index, feed, etc
|
|
# or 1 (bash return value 'false') if it is a blogpost
|
|
declare non_blogpost_files
|
|
declare index_file
|
|
declare archive_index
|
|
declare gophermap
|
|
declare gemini_index
|
|
declare tags_index
|
|
declare footer_file
|
|
declare header_file
|
|
declare prefix_tags
|
|
declare html_exclude
|
|
is_boilerplate_file() {
|
|
name=${1#./}
|
|
# First check against user-defined non-blogpost pages
|
|
for item in "${non_blogpost_files[@]}"; do
|
|
[[ "$name" == "$item" ]] && return 0
|
|
done
|
|
|
|
case $name in
|
|
"$index_file" | "$archive_index" | "$gophermap" | "$gemini_index" | "$tags_index" | "$footer_file" | "$header_file" | "$prefix_tags"*)
|
|
return 0
|
|
;;
|
|
*) # Check for excluded
|
|
for excl in "${html_exclude[@]}"; do
|
|
[[ $name == "$excl" ]] && return 0
|
|
done
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|