commit 710ea86850e41ea1d189dfe53fa59a7f0d45be5d
parent fb4822fe457f8939ca09ab284d1137867ba50a20
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 26 Jun 2024 23:51:13 +0200
Add feed autodiscovery to header
* fix js script
Diffstat:
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -4,7 +4,7 @@ include(cmake/prelude.cmake)
project(
stamd
- VERSION 0.2.4
+ VERSION 0.2.5
DESCRIPTION "Static Markdown Page Generator"
HOMEPAGE_URL "https://git.dimitrijedobrota.com/stamd.git"
LANGUAGES CXX
diff --git a/source/article.cpp b/source/article.cpp
@@ -60,10 +60,11 @@ void article::print_categories(std::ostream& ost,
ost << html::nav().set("class", "categories");
ost << html::h3("Categories: ");
ost << html::p();
- for (auto ctgry : categories)
+ for (const auto& category : categories)
{
+ auto ctgry = category;
normalize(ctgry);
- ost << html::a(ctgry, {{"href", std::format("./{}.html", ctgry)}});
+ ost << html::a(category, {{"href", std::format("./{}.html", ctgry)}});
}
ost << html::p();
ost << html::nav();
@@ -90,6 +91,16 @@ void article::write_header(std::ostream& ost) const
static const attributeList description = {{"name", "description"},
{"content", description_s}};
+ static const attributeList rss = {{"rel", "alternate"},
+ {"type", "application/atom+xml"},
+ {"title", "RSS feed"},
+ {"href", "/blog/rss.xml"}};
+
+ static const attributeList atom = {{"rel", "alternate"},
+ {"type", "application/atom+xml"},
+ {"title", "Atom feed"},
+ {"href", "/blog/atom.xml"}};
+
ost << html::doctype();
ost << html::html().set("lang", get_language());
ost << html::head()
@@ -99,6 +110,8 @@ void article::write_header(std::ostream& ost) const
.add(html::meta(description))
.add(html::link(style).set("href", "/css/index.css"))
.add(html::link(style).set("href", "/css/colors.css"))
+ .add(html::link(rss))
+ .add(html::link(atom))
.add(html::link(icon)
.set("sizes", "32x32")
.set("href", "/img/favicon-32x32.png"))
@@ -147,7 +160,7 @@ void article::write_footer(std::ostream& ost) const
ost << html::div();
ost << html::script(" ")
.set("type", "text/javascript")
- .set("source", "/scripts/main.js");
+ .set("src", "/scripts/main.js");
ost << html::body();
ost << html::html();
}
diff --git a/source/index.cpp b/source/index.cpp
@@ -105,11 +105,12 @@ void create_atom(std::ostream& ost,
ost << xml();
ost << atom::feed();
ost << atom::title(name);
- ost << atom::link(" ").set("href", base);
- ost << atom::link(" ", {{"rel", "self"}, {"href", loc}});
ost << atom::id(base);
ost << atom::updated(std::format(rfc3339_f, time));
ost << atom::author().add(atom::name(name));
+ ost << atom::link(" ", {{"rel", "self"}, {"href", loc}});
+ ost << atom::link(
+ " ", {{"href", base}, {"rel", "alternate"}, {"type", "text/html"}});
for (const auto& article : articles)
{