all repos — archive/homestead @ a67e38d1a82c95db5bd24183e81b31438f60dd2c

My future indieweb platform

feat: add configurable navigation

Alan Pearce
commit

a67e38d1a82c95db5bd24183e81b31438f60dd2c

parent

550562ec8b147439689bb3d4abdc406ace54a7db

M config/default.tomlconfig/default.toml
@@ -7,6 +7,10 @@ [site.author]
name = "John Doe" photo = "/static/johndoe.jpg" +[[site.nav]] +text = "Home" +url = "/" + [posts] folder = "./posts"
M src/responders.jssrc/responders.js
@@ -70,6 +70,12 @@ ".h-card .u-photo": {
alt: config.site.author.name, src: config.site.author.photo }, + "header nav li": config.site.nav.map(l => ({ + a: { + href: l.url, + _text: l.text + } + })), "body > main": pageElement.outerHTML }).outerHTML.trim(); }
M src/templates/layout.htmlsrc/templates/layout.html
@@ -10,6 +10,11 @@ <a class="u-url" href="/">
<img class="u-photo" alt="" src="" /> <h1 class="p-name">hello world</h1> </a> + <nav> + <ul> + <li><a href="/">test link</a></li> + </ul> + </nav> </header> <main></main> </body>
M test/app.test.jstest/app.test.js
@@ -43,6 +43,8 @@ const $ = parseResponse(res);
t.is($("head > title").text(), "John Doe", "head title is site author"); t.is($("main").length, 1, "only one <main> tag"); + t.is($("nav a").first().text(), "Home", "nav link has text"); + t.is($("nav a").first().attr("href"), "/", "nav links to homepage"); const options = toMicroformatsOptions($); const count = await mf.countAsync(options);
M test/testsite/config.tomltest/testsite/config.toml
@@ -1,2 +1,6 @@
[posts] -folder = "./posts"+folder = "./posts" + +[[site.nav]] +text = "Home" +url = "/"