Generate blog catalog file
WebsiteBuilder now generates blog catalog files, containing a catalog of articles for each blog.
This commit is contained in:
parent
304ed3013f
commit
e2aa7f4ce8
|
@ -104,7 +104,6 @@ namespace Article {
|
|||
|
||||
bool reading_article_metadata = false;
|
||||
for (std::string const &line : cfg_lines) {
|
||||
std::cout << "[!] Line: " << line << "\n";
|
||||
// Check namespace
|
||||
if (reading_article_metadata) {
|
||||
std::string k_title = "Title=",
|
||||
|
|
|
@ -189,7 +189,7 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
|
|||
// Sort am list.
|
||||
am.sort(Article::Comparator::comp);
|
||||
// Generate blog catalog.
|
||||
std::string blog_html_catalog = "<ul>",
|
||||
std::string blog_html_catalog = "<ul>\n",
|
||||
last_date = "";
|
||||
std::string hr_month[] = {
|
||||
"January",
|
||||
|
@ -215,20 +215,30 @@ void build_blog_structure(std::string const &path, std::string const &prefix, st
|
|||
// the last article. If it doesn't, add a new group to the catalog.
|
||||
if (hr_date != last_date) {
|
||||
last_date = hr_date;
|
||||
blog_html_catalog += "<span><b>";
|
||||
blog_html_catalog += "\n\t<span><b>";
|
||||
blog_html_catalog += hr_date;
|
||||
blog_html_catalog += "</b></span>";
|
||||
blog_html_catalog += "</b></span>\n";
|
||||
}
|
||||
|
||||
blog_html_catalog += "<li><a href=\"./";
|
||||
blog_html_catalog += "\t<li><a href=\"./";
|
||||
blog_html_catalog += m->path;
|
||||
blog_html_catalog += "\">";
|
||||
blog_html_catalog += m->title;
|
||||
blog_html_catalog += "</a></li>";
|
||||
blog_html_catalog += "</a></li>\n";
|
||||
// Free memory as it's no longer needed.
|
||||
free(m);
|
||||
}
|
||||
blog_html_catalog += "</ul>";
|
||||
// Put catalog HTML into template and save it to the blog directory.
|
||||
std::filesystem::path catalog_output_path = obp;
|
||||
catalog_output_path /= "index.html";
|
||||
|
||||
std::string html_template = get_template(path);
|
||||
std::regex content_placeholder("<!--\\[_SWG: \\$CONTENT\\]-->");
|
||||
std::string catalog_html_contents = std::regex_replace(html_template, content_placeholder, blog_html_catalog);
|
||||
|
||||
FILE *catalog_output_file = fopen(catalog_output_path.c_str(), "w");
|
||||
fputs(catalog_html_contents.c_str(), catalog_output_file);
|
||||
fclose(catalog_output_file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue