mirror of
https://github.com/szymon-jozef/static-site-generator.git
synced 2026-09-07 12:10:42 +02:00
Added general config
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
[general]
|
||||||
|
lang = "en"
|
||||||
|
title = "Blog"
|
||||||
|
|
||||||
[contact]
|
[contact]
|
||||||
author = "author"
|
author = "author"
|
||||||
email = "email@example.com"
|
email = "email@example.com"
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ Config get_config(const std::string &CONFIG_FILE) {
|
|||||||
toml_table["contact"]["signal"].value_or(""),
|
toml_table["contact"]["signal"].value_or(""),
|
||||||
};
|
};
|
||||||
|
|
||||||
Config config = {contact};
|
General general = {
|
||||||
|
toml_table["general"]["lang"].value_or(""),
|
||||||
|
toml_table["general"]["title"].value_or(""),
|
||||||
|
};
|
||||||
|
|
||||||
|
Config config = {contact, general};
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,14 @@ struct Contact {
|
|||||||
std::string signal;
|
std::string signal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct General {
|
||||||
|
std::string lang;
|
||||||
|
std::string title;
|
||||||
|
};
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
Contact contact;
|
Contact contact;
|
||||||
|
General general;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config get_config(const std::string &CONFIG_FILE);
|
Config get_config(const std::string &CONFIG_FILE);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include <catch2/catch_all.hpp>
|
#include <catch2/catch_all.hpp>
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
TEST_CASE("Checking config file read", "[config]") {
|
TEST_CASE("Checking config file read", "[config]") {
|
||||||
@@ -10,4 +11,6 @@ TEST_CASE("Checking config file read", "[config]") {
|
|||||||
REQUIRE(config.contact.author == "author");
|
REQUIRE(config.contact.author == "author");
|
||||||
REQUIRE(config.contact.email == "email@example.com");
|
REQUIRE(config.contact.email == "email@example.com");
|
||||||
REQUIRE(config.contact.signal == "signal url");
|
REQUIRE(config.contact.signal == "signal url");
|
||||||
|
REQUIRE(config.general.lang == "en");
|
||||||
|
REQUIRE(config.general.title == "Blog");
|
||||||
}
|
}
|
||||||
|
|||||||
24
templates/index.html
Normal file
24
templates/index.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="{{lang}}">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{{title}}</title>
|
||||||
|
<link rel="stylesheet" href="/style/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>{{title}}</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<nav id="nav">
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<ol id="posts">
|
||||||
|
|
||||||
|
</ol>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user