added build_index() function

This commit is contained in:
2026-01-12 23:04:37 +01:00
parent e542115cb8
commit a89e4bb60f
6 changed files with 92 additions and 8 deletions

View File

@@ -2,6 +2,17 @@
#include "config/config.hpp"
#include "format/format.hpp"
std::string build_index(const std::string &TEMPLATE, const Page &PAGE,
const Information &INFORMATION) {
std::string result = TEMPLATE;
result = format_file(result, "{{lang}}", INFORMATION.config.general.lang);
result = format_file(result, "{{head}}", PAGE.head);
result = format_file(result, "{{header}}", PAGE.header);
result = format_file(result, "{{main}}", PAGE.main);
result = format_file(result, "{{footer}}", PAGE.footer);
return result;
}
std::string build_header(const std::string &TEMPLATE,
const Information &INFORMATION) {
std::string result =
@@ -22,10 +33,10 @@ std::string build_footer(const std::string &TEMPLATE,
const Information &INFORMATION) {
std::string result = TEMPLATE;
result =
format_file_conditionally(TEMPLATE, "{{if email}}", "{{endif}}",
format_file_conditionally(result, "{{if email}}", "{{endif}}",
"{{email}}", INFORMATION.config.contact.email);
result = format_file_conditionally(TEMPLATE, "{{if signal}}", "{{endif}}",
result = format_file_conditionally(result, "{{if signal}}", "{{endif}}",
"{{signal}}",
INFORMATION.config.contact.signal);
return result;