Fix blog directory structure

Blog contents are now saved on a new subdirectory of "output" called
"blog".
This commit is contained in:
luca0N! 2022-03-04 17:40:53 -03:00
parent 7eb540099e
commit ba706016b9
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 6 additions and 4 deletions

View File

@ -107,10 +107,12 @@ std::string get_template(std::string const &path) {
} }
void build_blog_structure(std::string const &path, std::string const &prefix, std::list<std::string> const &articles, Blog *blog) { void build_blog_structure(std::string const &path, std::string const &prefix, std::list<std::string> const &articles, Blog *blog) {
std::filesystem::path obp = get_output_path(path) /= blog->dir; // Output Blog Path std::filesystem::path obp = get_output_path(path); // Output Blog Path
obp /= "blog";
obp /= blog->dir;
try { try {
// Create blog directory // Create blog directory
if (!std::filesystem::exists(obp)) std::filesystem::create_directory(obp); if (!std::filesystem::exists(obp)) std::filesystem::create_directories(obp);
} catch (std::filesystem::filesystem_error const &e) { } catch (std::filesystem::filesystem_error const &e) {
std::cerr << "error: failed to create directory for blog \"" << blog->name << "\": " << e.what() << std::endl; std::cerr << "error: failed to create directory for blog \"" << blog->name << "\": " << e.what() << std::endl;
exit(RETURN_FAILED_UNKNOWN_ERROR); exit(RETURN_FAILED_UNKNOWN_ERROR);
@ -134,8 +136,8 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
// directories later as needed. // directories later as needed.
try { try {
// Create directory for the year of this article if it doesn't exist. // Create directory for the year of this article if it doesn't exist.
std::filesystem::path oad = obp; std::filesystem::path oad = obp; // Output Article Directory
oad /= year; // Output Article Directory oad /= year;
if (!std::filesystem::exists(oad)) std::filesystem::create_directory(oad); if (!std::filesystem::exists(oad)) std::filesystem::create_directory(oad);
// Do the same for the article month. // Do the same for the article month.