luanti-web/site_generator/functions/03_html_helpers.sh
2025-06-21 15:58:52 +02:00

38 lines
1.3 KiB
Bash

#!/bin/bash
# 03_html_helpers.sh - Funktionen zum Erstellen von Header und Footer
generate_html_header() {
local current_page_title="$1"
local relative_path_prefix="${2:-.}"
local active_page_id="${3:-}"
local active_class_home=""; local active_class_worlds=""; local active_class_downloads=""
case "$active_page_id" in
home) active_class_home="active" ;;
worlds) active_class_worlds="active" ;;
downloads) active_class_downloads="active" ;;
esac
local header_file
header_file=$(mktemp)
render_template "${TEMPLATE_DIR_PATH}/html_header.template" "$header_file" \
"current_page_title" "$current_page_title" \
"relative_path_prefix" "$relative_path_prefix" \
"active_class_home" "$active_class_home" \
"active_class_worlds" "$active_class_worlds" \
"active_class_downloads" "$active_class_downloads" \
"CACHE_BUSTER" "$CACHE_BUSTER" \
"SITE_TITLE" "$SITE_TITLE"
cat "$header_file"
rm "$header_file"
}
generate_html_footer() {
local footer_file
footer_file=$(mktemp)
render_template "${TEMPLATE_DIR_PATH}/html_footer.template" "$footer_file" \
"CURRENT_YEAR" "$CURRENT_YEAR" \
"SITE_TITLE" "$SITE_TITLE" \
"SITE_OWNER_NAME" "$SITE_OWNER_NAME"
cat "$footer_file"
rm "$footer_file"
}