stamd

Static Markdown Page Generator
git clone git://git.dimitrijedobrota.com/stamd.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit a9307c02b44429cbec421ee24141b7427bc10b1c
parent 3390e3be634ba5943cef85e6d83eb81764b4e942
author Dimitrije Dobrota < mail@dimitrijedobrota.com >
date Sat, 3 May 2025 09:47:01 +0200

Utilize common tag shorthands

Diffstat:
M source/article.cpp | ++++++++++++++++++++ --------------------------------------------------------------
M source/indexer.cpp | ++++ --------------

2 files changed, 24 insertions(+), 80 deletions(-)


diff --git a/ source/article.cpp b/ source/article.cpp

@@ -110,8 +110,8 @@ hemplate::element Article::print_categories(const categories_t& categories)

{
auto ctgry = category;
normalize(ctgry);
return a {
{{"href", std::format("./{}.html", ctgry)}},
return aHref {
std::format("./{}.html", ctgry),
category,
};
}

@@ -125,76 +125,30 @@ hemplate::element Article::write(const content_t& content) const

using namespace hemplate::html; // NOLINT

return element {
doctype {},
doctype {},
html {
{{"lang", get_language()}},
head {
title {get_title()},
},

// Meta tags
meta {
{{"charset", "UTF-8"}},
},
meta {
{{"name", "author"}, {"content", get_author()}},
},
meta {{
{"name", "description"},
{"content", get_desciprtion()},
}},
meta {{
{"name", "keywords"},
{"content", get_keywords()},
}},
meta {
{{"content", "width=device-width, initial-scale=1"},
{"name", "viewport"}}
},
metaUTF8 {},
metaName {"author", get_author()},
metaName {"description", get_desciprtion()},
metaName {"keywords", get_keywords()},
metaName {"viewport", "width=device-width, initial-scale=1"},

// Stylesheets
link {{
{"rel", "stylesheet"},
{"type", "text/css"},
{"href", "/css/index.css"},
}},

link {{
{"rel", "stylesheet"},
{"type", "text/css"},
{"href", "/css/colors.css"},
}},

// Rss feed
link {{
{"rel", "alternate"},
{"type", "application/atom+xml"},
{"title", "RSS feed"},
{"href", "/blog/rss.xml"},
}},

// Atom feed
link {{
{"rel", "alternate"},
{"type", "application/atom+xml"},
{"title", "Atom feed"},
{"href", "/blog/atom.xml"},
}},

// Icons
link {{
{"rel", "icon"},
{"type", "image/png"},
{"sizes", "32x32"},
{"href", "/img/favicon-32x32.png"},
}},

link {{
{"rel", "icon"},
{"type", "image/png"},
{"sizes", "16x16"},
{"href", "/img/favicon-16x16.png"},
}},
linkStylesheet {"/css/index.css"},
linkStylesheet {"/css/colors.css"},

element {
linkRss {"RSS feed", "/blog/rss.xml"},
linkAtom {"Atom feed", "/blog/atom.xml"},
},

// Icons
linkIcon {"32x32", "/img/favicon-32x32.png"},
linkIcon {"16x16", "/img/favicon-16x16.png"},
},
body {
input {{
{"type", "checkbox"},

diff --git a/ source/indexer.cpp b/ source/indexer.cpp

@@ -77,10 +77,7 @@ void Indexer::create_index(std::ostream& ost, const std::string& doc_title)


return li {
span {article->get_date(), " -&nbsp"},
a {
{{"href", article->get_filename()}},
article->get_title(),
},
aHref {article->get_filename(), article->get_title()},
};
}
),

@@ -105,15 +102,8 @@ void Indexer::create_atom(std::ostream& ost, const std::string& doc_title) const

id {base_url},
updated {format_time_now()},
author {name {author_name}},
link {{
{"href", base_url + "/atom.xml"},
{"rel", "self"},
}},
link {{
{"href", base_url + "blog/atom.xml"},
{"rel", "alternate"},
{"type", "text/html"},
}},
linkSelf {base_url + "/atom.xml"},
linkAlternate {base_url + "blog/atom.xml"},
feed {
transform(
m_articles,

@@ -128,7 +118,7 @@ void Indexer::create_atom(std::ostream& ost, const std::string& doc_title) const

return entry {
title {art_title},
id {base_url + filename},
link {{{"href", base_url + filename}}},
linkHref {base_url + filename},
updated {format_time(parse_time((date)))},
summary {art_summary},
};